Skip to content

Commit 8e10cf7

Browse files
feat: add stop workspace button with confirmation dialog
- Add stop workspace button with square icon that replaces start button for running workspaces - Implement confirmation dialog for stop operation to prevent accidental stops - Button shows only when workspace status allows stop action - Uses existing stopWorkspace API mutation - Follows existing UI patterns for workspace actions Fixes #18298 Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
1 parent dc5f69e commit 8e10cf7

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import { Avatar } from "components/Avatar/Avatar";
1818
import { AvatarData } from "components/Avatar/AvatarData";
1919
import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton";
2020
import { Button } from "components/Button/Button";
21+
import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";
2122
import { ExternalImage } from "components/ExternalImage/ExternalImage";
2223
import { VSCodeIcon } from "components/Icons/VSCodeIcon";
2324
import { VSCodeInsidersIcon } from "components/Icons/VSCodeInsidersIcon";
@@ -49,6 +50,7 @@ import {
4950
BanIcon,
5051
PlayIcon,
5152
RefreshCcwIcon,
53+
SquareIcon,
5254
SquareTerminalIcon,
5355
} from "lucide-react";
5456
import {
@@ -74,6 +76,7 @@ import {
7476
type PropsWithChildren,
7577
type ReactNode,
7678
useMemo,
79+
useState,
7780
} from "react";
7881
import { useMutation, useQuery, useQueryClient } from "react-query";
7982
import { useNavigate } from "react-router-dom";
@@ -491,6 +494,9 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({
491494
onError: onActionError,
492495
});
493496

497+
// State for stop confirmation dialog
498+
const [isStopConfirmOpen, setIsStopConfirmOpen] = useState(false);
499+
494500
const isRetrying =
495501
startWorkspaceMutation.isPending ||
496502
stopWorkspaceMutation.isPending ||
@@ -535,6 +541,16 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({
535541
</PrimaryAction>
536542
)}
537543

544+
{abilities.actions.includes("stop") && (
545+
<PrimaryAction
546+
onClick={() => setIsStopConfirmOpen(true)}
547+
isLoading={stopWorkspaceMutation.isPending}
548+
label="Stop workspace"
549+
>
550+
<SquareIcon />
551+
</PrimaryAction>
552+
)}
553+
538554
{abilities.actions.includes("updateAndStart") && (
539555
<>
540556
<PrimaryAction
@@ -573,6 +589,21 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({
573589
disabled={!abilities.canAcceptJobs}
574590
/>
575591
</div>
592+
593+
{/* Stop workspace confirmation dialog */}
594+
<ConfirmDialog
595+
open={isStopConfirmOpen}
596+
title="Stop workspace"
597+
description={`Are you sure you want to stop the workspace "${workspace.name}"? This will terminate all running processes and disconnect any active sessions.`}
598+
confirmText="Stop"
599+
onClose={() => setIsStopConfirmOpen(false)}
600+
onConfirm={() => {
601+
stopWorkspaceMutation.mutate({});
602+
setIsStopConfirmOpen(false);
603+
}}
604+
type="delete"
605+
loading={stopWorkspaceMutation.isPending}
606+
/>
576607
</TableCell>
577608
);
578609
};

0 commit comments

Comments
 (0)