mirror of
https://github.com/coder/coder.git
synced 2025-07-18 14:17:22 +00:00
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.
This commit is contained in:
@ -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(
|
||||
|
Reference in New Issue
Block a user