-
Notifications
You must be signed in to change notification settings - Fork 899
feat: Delete workspace #1822
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Delete workspace #1822
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -40,6 +40,7 @@ export type WorkspaceEvent = | |
| { type: "GET_WORKSPACE"; workspaceId: string } | ||
| { type: "START" } | ||
| { type: "STOP" } | ||
| { type: "DELETE" } | ||
| { type: "UPDATE" } | ||
| { type: "CANCEL" } | ||
| { type: "LOAD_MORE_BUILDS" } | ||
|
@@ -136,6 +137,7 @@ export const workspaceMachine = createMachine( | |
on: { | ||
START: "requestingStart", | ||
STOP: "requestingStop", | ||
DELETE: "requestingDelete", | ||
UPDATE: "refreshingTemplate", | ||
CANCEL: "requestingCancel", | ||
}, | ||
|
@@ -170,6 +172,21 @@ export const workspaceMachine = createMachine( | |
}, | ||
}, | ||
}, | ||
requestingDelete: { | ||
entry: "clearBuildError", | ||
invoke: { | ||
id: "deleteWorkspace", | ||
src: "deleteWorkspace", | ||
onDone: { | ||
target: "idle", | ||
actions: ["assignBuild", "refreshTimeline"], | ||
}, | ||
onError: { | ||
target: "idle", | ||
actions: ["assignBuildError", "displayBuildError"], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do these show an error toast or something similar? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, and now that you mention it I should test for it. The component is called Snackbar. Oh but I think redirecting will stop it from happening :/ |
||
}, | ||
}, | ||
}, | ||
requestingCancel: { | ||
entry: "clearCancellationMessage", | ||
invoke: { | ||
|
@@ -428,6 +445,13 @@ export const workspaceMachine = createMachine( | |
throw Error("Cannot stop workspace without workspace id") | ||
} | ||
}, | ||
deleteWorkspace: async (context) => { | ||
if (context.workspace) { | ||
return await API.deleteWorkspace(context.workspace.id) | ||
} else { | ||
throw Error("Cannot delete workspace without workspace id") | ||
} | ||
}, | ||
cancelWorkspace: async (context) => { | ||
if (context.workspace) { | ||
return await API.cancelWorkspaceBuild(context.workspace.latest_build.id) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: Nice 😎