Skip to content

Commit 5e3a225

Browse files
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>
1 parent 44d4646 commit 5e3a225

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 36 additions & 1 deletion
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,20 @@ 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+
/>
576606
</TableCell>
577607
);
578608
};
@@ -593,7 +623,12 @@ const PrimaryAction: FC<PrimaryActionProps> = ({
593623
<TooltipProvider>
594624
<Tooltip>
595625
<TooltipTrigger asChild>
596-
<Button variant="outline" size="icon-lg" onClick={onClick}>
626+
<Button
627+
variant="outline"
628+
size="icon-lg"
629+
onClick={onClick}
630+
disabled={isLoading}
631+
>
597632
<Spinner loading={isLoading}>{children}</Spinner>
598633
<span className="sr-only">{label}</span>
599634
</Button>

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy