- Notifications
You must be signed in to change notification settings - Fork914
feat: add stop workspace button with confirmation dialog#18372
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Open
blink-so wants to merge6 commits intomainChoose a base branch fromfeat/stop-workspace-button
base:main
Could not load branches
Branch not found:{{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline, and old review comments may become outdated.
Uh oh!
There was an error while loading.Please reload this page.
Open
Changes fromall commits
Commits
Show all changes
6 commits Select commitHold shift + click to select a range
8e10cf7
feat: add stop workspace button with confirmation dialog
blink-so[bot]cb33963
feat: disable stop button during loading to prevent duplicate clicks
blink-so[bot]0d6032a
fix: remove unsupported loading prop from ConfirmDialog
blink-so[bot]b779d6f
fix: remove disabled prop from stop workspace button
blink-so[bot]a26067d
fix: remove empty line to fix biome formatting
blink-so[bot]ec096f8
refactor: remove unused disabled prop from PrimaryAction
blink-so[bot]File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Jump to file
Failed to load files.
Loading
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
37 changes: 36 additions & 1 deletionsite/src/pages/WorkspacesPage/WorkspacesTable.tsx
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<WorkspaceActionsCellProps> = ({ | ||
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<WorkspaceActionsCellProps> = ({ | ||
</PrimaryAction> | ||
)} | ||
{abilities.actions.includes("stop") && ( | ||
<PrimaryAction | ||
onClick={() => setIsStopConfirmOpen(true)} | ||
isLoading={stopWorkspaceMutation.isPending} | ||
code-asher marked this conversation as resolved. Show resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
label="Stop workspace" | ||
> | ||
<SquareIcon /> | ||
</PrimaryAction> | ||
)} | ||
{abilities.actions.includes("updateAndStart") && ( | ||
<> | ||
<PrimaryAction | ||
@@ -573,6 +589,20 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({ | ||
disabled={!abilities.canAcceptJobs} | ||
/> | ||
</div> | ||
{/* Stop workspace confirmation dialog */} | ||
<ConfirmDialog | ||
open={isStopConfirmOpen} | ||
title="Stop workspace" | ||
description={`Are you sure you want to stop the workspace "${workspace.name}"? This will terminate all running processes and disconnect any active sessions.`} | ||
confirmText="Stop" | ||
onClose={() => setIsStopConfirmOpen(false)} | ||
onConfirm={() => { | ||
stopWorkspaceMutation.mutate({}); | ||
setIsStopConfirmOpen(false); | ||
}} | ||
type="delete" | ||
/> | ||
</TableCell> | ||
); | ||
}; | ||
@@ -593,7 +623,12 @@ const PrimaryAction: FC<PrimaryActionProps> = ({ | ||
<TooltipProvider> | ||
<Tooltip> | ||
<TooltipTrigger asChild> | ||
<Button | ||
variant="outline" | ||
size="icon-lg" | ||
onClick={onClick} | ||
disabled={isLoading} | ||
> | ||
<Spinner loading={isLoading}>{children}</Spinner> | ||
<span className="sr-only">{label}</span> | ||
</Button> | ||
Oops, something went wrong.
Uh oh!
There was an error while loading.Please reload this page.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.