Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 66ad86a

Browse files
authored
fix: Update workspace wasn't using the latest build (#4001)
This was an oversight in a prior contribution. It broke the update button, but fixed the other cases.
1 parent 43f368d commit 66ad86a

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

site/src/xServices/workspace/workspaceXService.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ export const workspaceMachine = createMachine(
9292
getTemplate: {
9393
data: TypesGen.Template
9494
}
95+
startWorkspaceWithLatestTemplate: {
96+
data: TypesGen.WorkspaceBuild
97+
}
9598
startWorkspace: {
9699
data: TypesGen.WorkspaceBuild
97100
}
@@ -212,7 +215,7 @@ export const workspaceMachine = createMachine(
212215
START: "requestingStart",
213216
STOP: "requestingStop",
214217
ASK_DELETE: "askingDelete",
215-
UPDATE: "refreshingTemplate",
218+
UPDATE: "requestingStartWithLatestTemplate",
216219
CANCEL: "requestingCancel",
217220
},
218221
},
@@ -222,6 +225,21 @@ export const workspaceMachine = createMachine(
222225
CANCEL_DELETE: "idle",
223226
},
224227
},
228+
requestingStartWithLatestTemplate: {
229+
entry: "clearBuildError",
230+
invoke: {
231+
id: "startWorkspaceWithLatestTemplate",
232+
src: "startWorkspaceWithLatestTemplate",
233+
onDone: {
234+
target: "idle",
235+
actions: ["assignBuild", "refreshTimeline"],
236+
},
237+
onError: {
238+
target: "idle",
239+
actions: ["assignBuildError"],
240+
},
241+
},
242+
},
225243
requestingStart: {
226244
entry: "clearBuildError",
227245
invoke: {
@@ -524,6 +542,13 @@ export const workspaceMachine = createMachine(
524542
throw Error("Cannot get template without workspace")
525543
}
526544
},
545+
startWorkspaceWithLatestTemplate: async (context) => {
546+
if (context.workspace && context.template) {
547+
return await API.startWorkspace(context.workspace.id, context.template.active_version_id)
548+
} else {
549+
throw Error("Cannot start workspace without workspace id")
550+
}
551+
},
527552
startWorkspace: async (context) => {
528553
if (context.workspace) {
529554
return await API.startWorkspace(

0 commit comments

Comments
 (0)