Skip to content

feat: add orphan option to workspace delete in UI #10654

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 7 commits into from
Nov 14, 2023
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
fixed stories
  • Loading branch information
Kira-Pilot committed Nov 14, 2023
commit 176125af609c3ee12e1ab5edd12b199d6ee5af67
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ const args: ComponentProps<typeof WorkspaceDeleteDialog> = {
isOpen: true,
onCancel: () => {},
onConfirm: () => {},
workspaceBuildDateStr: "2 days ago",
};

export const NotTemplateAdmin: Story = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import { useId, useState, FormEvent } from "react";
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
import { type Interpolation, type Theme } from "@emotion/react";
import { colors } from "theme/colors";
import dayjs from "dayjs";
import TextField from "@mui/material/TextField";
import { docs } from "utils/docs";
import Link from "@mui/material/Link";
Expand Down Expand Up @@ -68,9 +67,17 @@ interface WorkspaceDeleteDialogProps {
isOpen: boolean;
onCancel: () => void;
onConfirm: (arg: CreateWorkspaceBuildRequest["orphan"]) => void;
workspaceBuildDateStr: string;
}
export const WorkspaceDeleteDialog = (props: WorkspaceDeleteDialogProps) => {
const { workspace, canUpdateTemplate, isOpen, onCancel, onConfirm } = props;
const {
workspace,
canUpdateTemplate,
isOpen,
onCancel,
onConfirm,
workspaceBuildDateStr,
} = props;
const hookId = useId();
const [userConfirmationText, setUserConfirmationText] = useState("");
const [orphanWorkspace, setOrphanWorkspace] =
Expand Down Expand Up @@ -106,7 +113,7 @@ export const WorkspaceDeleteDialog = (props: WorkspaceDeleteDialogProps) => {
<p className="label">workspace</p>
</div>
<div>
<p className="info">{dayjs(workspace.created_at).fromNow()}</p>
<p className="info">{workspaceBuildDateStr}</p>
<p className="label">created</p>
</div>
</div>
Expand Down
2 changes: 2 additions & 0 deletions site/src/pages/WorkspacePage/WorkspaceReadyPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import { decreaseDeadline, increaseDeadline } from "api/queries/workspaces";
import { getErrorMessage } from "api/errors";
import { displaySuccess, displayError } from "components/GlobalSnackbar/utils";
import { WorkspaceDeleteDialog } from "./WorkspaceDeleteDialog";
import dayjs from "dayjs";

interface WorkspaceReadyPageProps {
workspaceState: StateFrom<typeof workspaceMachine>;
Expand Down Expand Up @@ -224,6 +225,7 @@ export const WorkspaceReadyPage = ({
onConfirm={(orphan) => {
workspaceSend({ type: "DELETE", orphan });
}}
workspaceBuildDateStr={dayjs(workspace.created_at).fromNow()}
/>
<UpdateBuildParametersDialog
missedParameters={missedParameters ?? []}
Expand Down