From 79c9591d47a85d4a52fe70f75fe1e3b659bede24 Mon Sep 17 00:00:00 2001 From: Kyle Carberry Date: Mon, 12 Sep 2022 01:12:20 +0000 Subject: [PATCH] fix: Update workspace wasn't using the latest build This was an oversight in a prior contribution. It broke the update button, but fixed the other cases. --- .../xServices/workspace/workspaceXService.ts | 27 ++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/site/src/xServices/workspace/workspaceXService.ts b/site/src/xServices/workspace/workspaceXService.ts index c9377410a6285..1f3b8192977fb 100644 --- a/site/src/xServices/workspace/workspaceXService.ts +++ b/site/src/xServices/workspace/workspaceXService.ts @@ -92,6 +92,9 @@ export const workspaceMachine = createMachine( getTemplate: { data: TypesGen.Template } + startWorkspaceWithLatestTemplate: { + data: TypesGen.WorkspaceBuild + } startWorkspace: { data: TypesGen.WorkspaceBuild } @@ -212,7 +215,7 @@ export const workspaceMachine = createMachine( START: "requestingStart", STOP: "requestingStop", ASK_DELETE: "askingDelete", - UPDATE: "refreshingTemplate", + UPDATE: "requestingStartWithLatestTemplate", CANCEL: "requestingCancel", }, }, @@ -222,6 +225,21 @@ export const workspaceMachine = createMachine( CANCEL_DELETE: "idle", }, }, + requestingStartWithLatestTemplate: { + entry: "clearBuildError", + invoke: { + id: "startWorkspaceWithLatestTemplate", + src: "startWorkspaceWithLatestTemplate", + onDone: { + target: "idle", + actions: ["assignBuild", "refreshTimeline"], + }, + onError: { + target: "idle", + actions: ["assignBuildError"], + }, + }, + }, requestingStart: { entry: "clearBuildError", invoke: { @@ -524,6 +542,13 @@ export const workspaceMachine = createMachine( throw Error("Cannot get template without workspace") } }, + startWorkspaceWithLatestTemplate: async (context) => { + if (context.workspace && context.template) { + return await API.startWorkspace(context.workspace.id, context.template.active_version_id) + } else { + throw Error("Cannot start workspace without workspace id") + } + }, startWorkspace: async (context) => { if (context.workspace) { return await API.startWorkspace( pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy