A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/coder/coder/commit/5e3a225e3bfaa2ca03f9763d8a75b02c7a4d38db below:

add stop workspace button with confirmation dialog (#18372) · coder/coder@5e3a225 · GitHub

File tree Expand file treeCollapse file tree 1 file changed

+36

-1

lines changed

Filter options

Expand file treeCollapse file tree 1 file changed

+36

-1

lines changed Original file line number Diff line number Diff line change

@@ -18,6 +18,7 @@ import { Avatar } from "components/Avatar/Avatar";

18 18

import { AvatarData } from "components/Avatar/AvatarData";

19 19

import { AvatarDataSkeleton } from "components/Avatar/AvatarDataSkeleton";

20 20

import { Button } from "components/Button/Button";

21 +

import { ConfirmDialog } from "components/Dialogs/ConfirmDialog/ConfirmDialog";

21 22

import { ExternalImage } from "components/ExternalImage/ExternalImage";

22 23

import { VSCodeIcon } from "components/Icons/VSCodeIcon";

23 24

import { VSCodeInsidersIcon } from "components/Icons/VSCodeInsidersIcon";

@@ -49,6 +50,7 @@ import {

49 50

BanIcon,

50 51

PlayIcon,

51 52

RefreshCcwIcon,

53 +

SquareIcon,

52 54

SquareTerminalIcon,

53 55

} from "lucide-react";

54 56

import {

@@ -74,6 +76,7 @@ import {

74 76

type PropsWithChildren,

75 77

type ReactNode,

76 78

useMemo,

79 +

useState,

77 80

} from "react";

78 81

import { useMutation, useQuery, useQueryClient } from "react-query";

79 82

import { useNavigate } from "react-router-dom";

@@ -491,6 +494,9 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({

491 494

onError: onActionError,

492 495

});

493 496 497 +

// State for stop confirmation dialog

498 +

const [isStopConfirmOpen, setIsStopConfirmOpen] = useState(false);

499 + 494 500

const isRetrying =

495 501

startWorkspaceMutation.isPending ||

496 502

stopWorkspaceMutation.isPending ||

@@ -535,6 +541,16 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({

535 541

</PrimaryAction>

536 542

)}

537 543 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 + 538 554

{abilities.actions.includes("updateAndStart") && (

539 555

<>

540 556

<PrimaryAction

@@ -573,6 +589,20 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({

573 589

disabled={!abilities.canAcceptJobs}

574 590

/>

575 591

</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 +

/>

576 606

</TableCell>

577 607

);

578 608

};

@@ -593,7 +623,12 @@ const PrimaryAction: FC<PrimaryActionProps> = ({

593 623

<TooltipProvider>

594 624

<Tooltip>

595 625

<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 +

>

597 632

<Spinner loading={isLoading}>{children}</Spinner>

598 633

<span className="sr-only">{label}</span>

599 634

</Button>

You can’t perform that action at this time.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4