diff --git a/web/src/workspaces/workspace-table.tsx b/web/src/workspaces/workspace-table.tsx index 64377dd..fe14a8d 100644 --- a/web/src/workspaces/workspace-table.tsx +++ b/web/src/workspaces/workspace-table.tsx @@ -29,11 +29,6 @@ import { import { type Workspace, WorkspaceStatus } from "./types"; import { LoadingSpinner } from "@/components/ui/loading-spinner"; import { Badge } from "@/components/ui/badge"; -import { - Popover, - PopoverContent, - PopoverTrigger, -} from "@/components/ui/popover"; import { Input } from "@/components/ui/input"; import { useForm } from "react-hook-form"; import { number, object, pattern, size, string, type Infer } from "superstruct"; @@ -43,11 +38,15 @@ import { FormControl, FormField, FormItem, - FormLabel, FormMessage, } from "@/components/ui/form"; -import { Dialog, DialogContent, DialogTrigger } from "@/components/ui/dialog"; +import { Dialog, DialogTrigger } from "@/components/ui/dialog"; import { WorkspaceInfoDialog } from "./workspace-info-dialog"; +import { + Popover, + PopoverContent, + PopoverTrigger, +} from "@/components/ui/popover"; const WorkspaceTableRowContext = createContext( null as unknown as Workspace, @@ -211,19 +210,27 @@ function WorkspaceStatusButton() { function DeleteWorkspaceButton({ workspace }: { workspace: Workspace }) { const { toast } = useToast(); + const [isConfirmationOpen, setIsConfirmationOpen] = useState(false); const { deleteWorkspace, status } = useDeleteWorkspace(); + const isLoading = status.type === "loading"; useEffect(() => { - console.log(status.type); - if (status.type === "error") { - toast({ - title: `Failed to delete workspace ${workspace.name}.`, - action: ( - - Try again - - ), - }); + switch (status.type) { + case "error": + toast({ + title: `Failed to delete workspace ${workspace.name}.`, + action: ( + + Try again + + ), + }); + break; + case "ok": + closeConfirmation(); + break; + default: + break; } }, [toast, status.type, workspace.name]); @@ -231,10 +238,48 @@ function DeleteWorkspaceButton({ workspace }: { workspace: Workspace }) { await deleteWorkspace(workspace.name); } + function closeConfirmation() { + setIsConfirmationOpen(false); + } + return ( - + { + if (status.type !== "loading") { + setIsConfirmationOpen(opened); + } + }} + > + + + + +

+ If you delete this workspace, all data in it will be lost forever. +

+
+ + +
+
+
); }