From 5e3a225e3bfaa2ca03f9763d8a75b02c7a4d38db Mon Sep 17 00:00:00 2001 From: "blink-so[bot]" <211532188+blink-so[bot]@users.noreply.github.com> Date: Wed, 18 Jun 2025 17:49:26 +0500 Subject: [PATCH] feat: add stop workspace button with confirmation dialog (#18372) Co-authored-by: blink-so[bot] <211532188+blink-so[bot]@users.noreply.github.com> Co-authored-by: matifali <10648092+matifali@users.noreply.github.com> --- .../pages/WorkspacesPage/WorkspacesTable.tsx | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx index 92ba3fe7ae..2dc25c0a39 100644 --- a/site/src/pages/WorkspacesPage/WorkspacesTable.tsx +++ b/site/src/pages/WorkspacesPage/WorkspacesTable.tsx @@ -18,6 +18,7 @@ import { Avatar } from "components/Avatar/Avatar"; import { AvatarData } from "components/Avatar/AvatarData"; import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton"; import { Button } from "components/Button/Button"; +import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog"; import { ExternalImage } from "components/ExternalImage/ExternalImage"; import { VSCodeIcon } from "components/Icons/VSCodeIcon"; import { VSCodeInsidersIcon } from "components/Icons/VSCodeInsidersIcon"; @@ -49,6 +50,7 @@ import { BanIcon, PlayIcon, RefreshCcwIcon, + SquareIcon, SquareTerminalIcon, } from "lucide-react"; import { @@ -74,6 +76,7 @@ import { type PropsWithChildren, type ReactNode, useMemo, + useState, } from "react"; import { useMutation, useQuery, useQueryClient } from "react-query"; import { useNavigate } from "react-router-dom"; @@ -491,6 +494,9 @@ const WorkspaceActionsCell: FC = ({ onError: onActionError, }); + // State for stop confirmation dialog + const [isStopConfirmOpen, setIsStopConfirmOpen] = useState(false); + const isRetrying = startWorkspaceMutation.isPending || stopWorkspaceMutation.isPending || @@ -535,6 +541,16 @@ const WorkspaceActionsCell: FC = ({ )} + {abilities.actions.includes("stop") && ( + setIsStopConfirmOpen(true)} + isLoading={stopWorkspaceMutation.isPending} + label="Stop workspace" + > + + + )} + {abilities.actions.includes("updateAndStart") && ( <> = ({ disabled={!abilities.canAcceptJobs} /> + + {/* Stop workspace confirmation dialog */} + setIsStopConfirmOpen(false)} + onConfirm={() => { + stopWorkspaceMutation.mutate({}); + setIsStopConfirmOpen(false); + }} + type="delete" + /> ); }; @@ -593,7 +623,12 @@ const PrimaryAction: FC = ({ -