Skip to content

feat: show deleted workspace after delete action #2208

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

Merged
merged 8 commits into from
Jun 9, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
added include_deleted param
  • Loading branch information
Kira-Pilot committed Jun 9, 2022
commit e48cc71f0f7949b7aa55add354da907dbfdf3bed
6 changes: 4 additions & 2 deletions site/src/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ export const getWorkspace = async (
workspaceId: string,
params?: TypesGen.WorkspaceOptions,
): Promise<TypesGen.Workspace> => {
console.log("in get Workspace API method", params)
const response = await axios.get<TypesGen.Workspace>(`/api/v2/workspaces/${workspaceId}`, { params })
return response.data
}
Expand Down Expand Up @@ -145,8 +144,11 @@ export const getWorkspaces = async (filter?: TypesGen.WorkspaceFilter): Promise<
export const getWorkspaceByOwnerAndName = async (
username = "me",
workspaceName: string,
params?: TypesGen.WorkspaceByOwnerAndNameParams,
): Promise<TypesGen.Workspace> => {
const response = await axios.get<TypesGen.Workspace>(`/api/v2/users/${username}/workspace/${workspaceName}`)
const response = await axios.get<TypesGen.Workspace>(`/api/v2/users/${username}/workspace/${workspaceName}`, {
params,
})
return response.data
}

Expand Down
12 changes: 7 additions & 5 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ export const workspaceMachine = createMachine(
requestingDelete: {
entry: "clearBuildError",
invoke: {
id: "deleteWorkspace", // delete the workspace
id: "deleteWorkspace",
src: "deleteWorkspace",
onDone: {
target: "gettingDeletedWorkspace",
Expand All @@ -204,14 +204,14 @@ export const workspaceMachine = createMachine(
gettingDeletedWorkspace: {
entry: ["clearGetWorkspaceError", "clearContext"],
invoke: {
id: "getDeletedWorkspace", // request deleted workspace
id: "getDeletedWorkspace",
src: "getDeletedWorkspace",
onDone: {
target: "idle",
actions: ["assignBuild", "refreshTimeline"],
},
onError: {
target: "idle", // error
target: "idle",
actions: ["assignBuildError", "displayBuildError"],
},
},
Expand Down Expand Up @@ -452,7 +452,7 @@ export const workspaceMachine = createMachine(
},
services: {
getWorkspace: async (_, event) => {
return await API.getWorkspaceByOwnerAndName(event.username, event.workspaceName)
return await API.getWorkspaceByOwnerAndName(event.username, event.workspaceName, { include_deleted: true })
},
getDeletedWorkspace: async (context) => {
if (context.workspace) {
Expand Down Expand Up @@ -498,7 +498,9 @@ export const workspaceMachine = createMachine(
},
refreshWorkspace: async (context) => {
if (context.workspace) {
return await API.getWorkspaceByOwnerAndName(context.workspace.owner_name, context.workspace.name)
return await API.getWorkspaceByOwnerAndName(context.workspace.owner_name, context.workspace.name, {
include_deleted: true,
})
} else {
throw Error("Cannot refresh workspace without id")
}
Expand Down