8000 feat: show deleted workspace after delete action by Kira-Pilot · Pull Request #2208 · coder/coder · GitHub
[go: up one dir, main page]

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
merged in main
  • Loading branch information
Kira-Pilot committed Jun 7, 2022
commit 2e26ef42517a13bc56e582ca4347548a948f5973
1 change: 0 additions & 1 deletion site/src/components/Workspace/Workspace.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { makeStyles } from "@material-ui/core/styles"
import { FC } from "react"
import * as TypesGen from "../../api/typesGenerated"
import { MONOSPACE_FONT_FAMILY } from "../../theme/constants"
import { getWorkspaceStatus, succeededToStatus } from "../../util/workspace"
import { BuildsTable } from "../BuildsTable/BuildsTable"
import { Margins } from "../Margins/Margins"
Expand Down
70 changes: 37 additions & 33 deletions site/src/pages/WorkspacePage/WorkspacePage.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { useMachine } from "@xstate/react"
import React, { useEffect } from "react"
import { useParams } from "react-router-dom"
import { Helmet } from "react-helmet"
import { useNavigate, useParams } from "react-router-dom"
import { DeleteWorkspaceDialog } from "../../components/DeleteWorkspaceDialog/DeleteWorkspaceDialog"
import { ErrorSummary } from "../../components/ErrorSummary/ErrorSummary"
import { FullScreenLoader } from "../../components/Loader/FullScreenLoader"
Expand All @@ -11,8 +12,10 @@ import { workspaceMachine } from "../../xServices/workspace/workspaceXService"
import { workspaceScheduleBannerMachine } from "../../xServices/workspaceSchedule/workspaceScheduleBannerXService"

export const WorkspacePage: React.FC = () => {
const { workspace: workspaceQueryParam } = useParams()
const workspaceId = firstOrItem(workspaceQueryParam, null)
const { username: usernameQueryParam, workspace: workspaceQueryParam } = useParams()
const navigate = useNavigate()
const username = firstOrItem(usernameQueryParam, null)
const workspaceName = firstOrItem(workspaceQueryParam, null)

const [workspaceState, workspaceSend] = useMachine(workspaceMachine)
const { workspace, resources, getWorkspaceError, getResourcesError, builds } = workspaceState.context
Expand All @@ -33,36 +36,37 @@ export const WorkspacePage: React.FC = () => {
return <FullScreenLoader />
} else {
return (
<Margins>
<Stack spacing={4}>
<>
<Workspace
bannerProps={{
isLoading: bannerState.hasTag("loading"),
onExtend: () => {
bannerSend({ type: "EXTEND_DEADLINE_DEFAULT", workspaceId: workspace.id })
},
}}
workspace={workspace}
handleStart={() => workspaceSend("START")}
handleStop={() => workspaceSend("STOP")}
handleDelete={() => workspaceSend("ASK_DELETE")}
handleUpdate={() => workspaceSend("UPDATE")}
handleCancel={() => workspaceSend("CANCEL")}
resources={resources}
getResourcesError={getResourcesError instanceof Error ? getResourcesError : undefined}
builds={builds}
/>
<DeleteWorkspaceDialog
isOpen={workspaceState.matches({ ready: { build: "askingDelete" } })}
handleCancel={() => workspaceSend("CANCEL_DELETE")}
handleConfirm={() => {
workspaceSend("DELETE")
}}
/>
</>
</Stack>
</Margins>
<>
<Helmet>
<title>{pageTitle(`${workspace.owner_name}/${workspace.name}`)}</title>
</Helmet>

<Workspace
bannerProps={{
isLoading: bannerState.hasTag("loading"),
onExtend: () => {
bannerSend({ type: "EXTEND_DEADLINE_DEFAULT", workspaceId: workspace.id })
},
}}
workspace={workspace}
handleStart={() => workspaceSend("START")}
handleStop={() => workspaceSend("STOP")}
handleDelete={() => workspaceSend("ASK_DELETE")}
handleUpdate={() => workspaceSend("UPDATE")}
handleCancel={() => workspaceSend("CANCEL")}
resources={resources}
getResourcesError={getResourcesError instanceof Error ? getResourcesError : undefined}
builds={builds}
/>
<DeleteWorkspaceDialog
isOpen={workspaceState.matches({ ready: { build: "askingDelete" } })}
handleCancel={() => workspaceSend("CANCEL_DELETE")}
handleConfirm={() => {
workspaceSend("DELETE")
navigate("/workspaces")
}}
/>
</>
)
}
}
6 changes: 2 additions & 4 deletions site/src/xServices/workspace/workspaceXService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,7 @@ export const workspaceMachine = createMachine(
},
services: {
getWorkspace: async (_, event) => {
// { deleted: true }
return await API.getWorkspace(event.workspaceId)
return await API.getWorkspaceByOwnerAndName(event.username, event.workspaceName)
},
getTemplate: async (context) => {
if (context.workspace) {
Expand Down Expand Up @@ -471,8 +470,7 @@ export const workspaceMachine = createMachine(
},
refreshWorkspace: async (context) => {
if (context.workspace) {
// need to add {deleted: true} here but there is a BE bug rn
return await API.getWorkspace(context.workspace.id)
return await API.getWorkspaceByOwnerAndName(context.workspace.owner_name, context.workspace.name)
} else {
throw Error("Cannot refresh workspace without id")
}
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.
0