Skip to content

Commit cb33963

Browse files
feat: disable stop button during loading to prevent duplicate clicks
- Add disabled prop to PrimaryActionProps interface - Implement disabled state in PrimaryAction component - Apply disabled prop to stop button when stopWorkspaceMutation is pending - Prevents accidental duplicate stop requests during operation Co-authored-by: matifali <10648092+matifali@users.noreply.github.com>
1 parent 8e10cf7 commit cb33963

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

site/src/pages/WorkspacesPage/WorkspacesTable.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,7 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({
545545
<PrimaryAction
546546
onClick={() => setIsStopConfirmOpen(true)}
547547
isLoading={stopWorkspaceMutation.isPending}
548+
disabled={stopWorkspaceMutation.isPending}
548549
label="Stop workspace"
549550
>
550551
<SquareIcon />
@@ -611,20 +612,27 @@ const WorkspaceActionsCell: FC<WorkspaceActionsCellProps> = ({
611612
type PrimaryActionProps = PropsWithChildren<{
612613
label: string;
613614
isLoading?: boolean;
615+
disabled?: boolean;
614616
onClick: () => void;
615617
}>;
616618

617619
const PrimaryAction: FC<PrimaryActionProps> = ({
618620
onClick,
619621
isLoading,
622+
disabled,
620623
label,
621624
children,
622625
}) => {
623626
return (
624627
<TooltipProvider>
625628
<Tooltip>
626629
<TooltipTrigger asChild>
627-
<Button variant="outline" size="icon-lg" onClick={onClick}>
630+
<Button
631+
variant="outline"
632+
size="icon-lg"
633+
onClick={onClick}
634+
disabled={disabled}
635+
>
628636
<Spinner loading={isLoading}>{children}</Spinner>
629637
<span className="sr-only">{label}</span>
630638
</Button>

0 commit comments

Comments
 (0)