@@ -92,6 +92,9 @@ export const workspaceMachine = createMachine(
92
92
getTemplate : {
93
93
data : TypesGen . Template
94
94
}
95
+ startWorkspaceWithLatestTemplate : {
96
+ data : TypesGen . WorkspaceBuild
97
+ }
95
98
startWorkspace : {
96
99
data : TypesGen . WorkspaceBuild
97
100
}
@@ -212,7 +215,7 @@ export const workspaceMachine = createMachine(
212
215
START : "requestingStart" ,
213
216
STOP : "requestingStop" ,
214
217
ASK_DELETE : "askingDelete" ,
215
- UPDATE : "refreshingTemplate " ,
218
+ UPDATE : "requestingStartWithLatestTemplate " ,
216
219
CANCEL : "requestingCancel" ,
217
220
} ,
218
221
} ,
@@ -222,6 +225,21 @@ export const workspaceMachine = createMachine(
222
225
CANCEL_DELETE : "idle" ,
223
226
} ,
224
227
} ,
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
+ } ,
225
243
requestingStart : {
226
244
entry : "clearBuildError" ,
227
245
invoke : {
@@ -524,6 +542,13 @@ export const workspaceMachine = createMachine(
524
542
throw Error ( "Cannot get template without workspace" )
525
543
}
526
544
} ,
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
+ } ,
527
552
startWorkspace : async ( context ) => {
528
553
if ( context . workspace ) {
529
554
return await API . startWorkspace (
0 commit comments