Open History to see the last commit
1import type {
2 ProjectScript,
3 ProjectScriptIcon,
4 ResolvedKeybindingsConfig,
5 T3ProjectFileScript,
6} from "@t3tools/contracts";
7import {
8 isAtomCommandInterrupted,
9 squashAtomCommandFailure,
10 type AtomCommandResult,
11} from "@t3tools/client-runtime/state/runtime";
12import {
13 BugIcon,
14 ChevronDownIcon,
15 DownloadIcon,
16 FlaskConicalIcon,
17 HammerIcon,
18 ListChecksIcon,
19 PlayIcon,
20 PlusIcon,
21 SettingsIcon,
22 WrenchIcon,
23} from "lucide-react";
24import React, { type FormEvent, type KeyboardEvent, useCallback, useMemo, useState } from "react";
25
26import {
27 keybindingValueForCommand,
28 decodeProjectScriptKeybindingRule,
29} from "~/lib/projectScriptKeybindings";
30import { keybindingFromKeyboardEvent } from "~/components/settings/KeybindingsSettings.logic";
31import {
32 commandForProjectScript,
33 nextProjectScriptId,
34 primaryProjectScript,
35} from "~/projectScripts";
36import { shortcutLabelForCommand } from "~/keybindings";
37import {
38 AlertDialog,
39 AlertDialogClose,
40 AlertDialogDescription,
41 AlertDialogFooter,
42 AlertDialogHeader,
43 AlertDialogPopup,
44 AlertDialogTitle,
45} from "./ui/alert-dialog";
46import { Button } from "./ui/button";
47import {
48 Dialog,
49 DialogDescription,
50 DialogFooter,
51 DialogHeader,
52 DialogPanel,
53 DialogPopup,
54 DialogTitle,
55} from "./ui/dialog";
56import { Group, GroupSeparator } from "./ui/group";
57import { Input } from "./ui/input";
58import { Label } from "./ui/label";
59import {
60 Menu,
61 MenuGroup,
62 MenuGroupLabel,
63 MenuItem,
64 MenuPopup,
65 MenuSeparator,
66 MenuShortcut,
67 MenuTrigger,
68} from "./ui/menu";
69import { Popover, PopoverPopup, PopoverTrigger } from "./ui/popover";
70import { Switch } from "./ui/switch";
71import { Textarea } from "./ui/textarea";
72import { Tooltip, TooltipPopup, TooltipTrigger } from "./ui/tooltip";
73import { cn } from "~/lib/utils";
74import {
75 THREAD_DETAILS_PANEL_CHEVRON_CLASS,
76 THREAD_DETAILS_PANEL_ICON_CLASS,
77 THREAD_DETAILS_PANEL_ROW_POPUP_CLASS,
78 THREAD_DETAILS_PANEL_ROW_CLASS,
79 THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS,
80 THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS,
81 THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS,
82 THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS,
83} from "./chat/threadDetailsPanelStyles";
84
85const SCRIPT_ICONS: Array<{ id: ProjectScriptIcon; label: string }> = [
86 { id: "play", label: "Play" },
87 { id: "test", label: "Test" },
88 { id: "lint", label: "Lint" },
89 { id: "configure", label: "Configure" },
90 { id: "build", label: "Build" },
91 { id: "debug", label: "Debug" },
92];
93
94function ScriptIcon({
95 icon,
96 className = "size-3.5",
97}: {
98 icon: ProjectScriptIcon;
99 className?: string;
100}) {
101 if (icon === "test") return <FlaskConicalIcon className={className} />;
102 if (icon === "lint") return <ListChecksIcon className={className} />;
103 if (icon === "configure") return <WrenchIcon className={className} />;
104 if (icon === "build") return <HammerIcon className={className} />;
105 if (icon === "debug") return <BugIcon className={className} />;
106 return <PlayIcon className={className} />;
107}
108
109export interface NewProjectScriptInput {
110 name: string;
111 command: string;
112 icon: ProjectScriptIcon;
113 runOnWorktreeCreate: boolean;
114 keybinding: string | null;
115 /** Optional URL to open in the in-app preview when this script runs. */
116 previewUrl: string | null;
117 /** When true, automatically open the preview panel pointed at `previewUrl`. */
118 autoOpenPreview: boolean;
119}
120
121export type ProjectScriptActionResult = AtomCommandResult<void, unknown>;
122
123const NO_FILE_SCRIPTS: ReadonlyArray<T3ProjectFileScript> = [];
124
125interface ProjectScriptsControlProps {
126 displayMode?: "toolbar" | "panel";
127 scripts: ReadonlyArray<ProjectScript>;
128 /** Scripts declared in the project's checked-in t3.json, offered for import. */
129 fileScripts?: ReadonlyArray<T3ProjectFileScript>;
130 keybindings: ResolvedKeybindingsConfig;
131 preferredScriptId?: string | null;
132 onRunScript: (script: ProjectScript) => void;
133 onAddScript: (input: NewProjectScriptInput) => Promise<ProjectScriptActionResult>;
134 onUpdateScript: (
135 scriptId: string,
136 input: NewProjectScriptInput,
137 ) => Promise<ProjectScriptActionResult>;
138 onDeleteScript: (scriptId: string) => Promise<ProjectScriptActionResult>;
139}
140
141export default function ProjectScriptsControl({
142 displayMode = "toolbar",
143 scripts,
144 fileScripts = NO_FILE_SCRIPTS,
145 keybindings,
146 preferredScriptId = null,
147 onRunScript,
148 onAddScript,
149 onUpdateScript,
150 onDeleteScript,
151}: ProjectScriptsControlProps) {
152 const isPanel = displayMode === "panel";
153 const ActionGroup = isPanel ? "div" : Group;
154 const panelAnchorRef = React.useRef<HTMLDivElement | null>(null);
155 const addScriptFormId = React.useId();
156 const [editingScriptId, setEditingScriptId] = useState<string | null>(null);
157 const [dialogOpen, setDialogOpen] = useState(false);
158 const [name, setName] = useState("");
159 const [command, setCommand] = useState("");
160 const [icon, setIcon] = useState<ProjectScriptIcon>("play");
161 const [iconPickerOpen, setIconPickerOpen] = useState(false);
162 const [runOnWorktreeCreate, setRunOnWorktreeCreate] = useState(false);
163 const [keybinding, setKeybinding] = useState("");
164 const [previewUrl, setPreviewUrl] = useState("");
165 const [autoOpenPreview, setAutoOpenPreview] = useState(false);
166 const [validationError, setValidationError] = useState<string | null>(null);
167 const [deleteConfirmOpen, setDeleteConfirmOpen] = useState(false);
168
169 const primaryScript = useMemo(() => {
170 if (preferredScriptId) {
171 const preferred = scripts.find((script) => script.id === preferredScriptId);
172 if (preferred) return preferred;
173 }
174 return primaryProjectScript(scripts);
175 }, [preferredScriptId, scripts]);
176 const importableScripts = useMemo(
177 () =>
178 fileScripts.filter(
179 (fileScript) =>
180 !scripts.some(
181 (script) =>
182 script.command === fileScript.command ||
183 script.name.toLowerCase() === fileScript.name.toLowerCase(),
184 ),
185 ),
186 [fileScripts, scripts],
187 );
188 const isEditing = editingScriptId !== null;
189 const dropdownItemClassName =
190 "data-highlighted:bg-transparent data-highlighted:text-foreground hover:bg-accent hover:text-accent-foreground focus-visible:bg-accent focus-visible:text-accent-foreground data-highlighted:hover:bg-accent data-highlighted:hover:text-accent-foreground data-highlighted:focus-visible:bg-accent data-highlighted:focus-visible:text-accent-foreground";
191
192 const captureKeybinding = (event: KeyboardEvent<HTMLInputElement>) => {
193 if (event.key === "Tab") return;
194 event.preventDefault();
195 if (event.key === "Backspace" || event.key === "Delete") {
196 setKeybinding("");
197 return;
198 }
199 const next = keybindingFromKeyboardEvent(event, navigator.platform);
200 if (!next) return;
201 setKeybinding(next);
202 };
203
204 const submitAddScript = async (event: FormEvent) => {
205 event.preventDefault();
206 const trimmedName = name.trim();
207 const trimmedCommand = command.trim();
208 if (trimmedName.length === 0) {
209 setValidationError("Name is required.");
210 return;
211 }
212 if (trimmedCommand.length === 0) {
213 setValidationError("Command is required.");
214 return;
215 }
216
217 setValidationError(null);
218 let payload: NewProjectScriptInput;
219 try {
220 const scriptIdForValidation =
221 editingScriptId ??
222 nextProjectScriptId(
223 trimmedName,
224 scripts.map((script) => script.id),
225 );
226 const keybindingRule = decodeProjectScriptKeybindingRule({
227 keybinding,
228 command: commandForProjectScript(scriptIdForValidation),
229 });
230 const trimmedPreviewUrl = previewUrl.trim();
231 payload = {
232 name: trimmedName,
233 command: trimmedCommand,
234 icon,
235 runOnWorktreeCreate,
236 keybinding: keybindingRule?.key ?? null,
237 previewUrl: trimmedPreviewUrl.length > 0 ? trimmedPreviewUrl : null,
238 autoOpenPreview: trimmedPreviewUrl.length > 0 ? autoOpenPreview : false,
239 } satisfies NewProjectScriptInput;
240 } catch (error) {
241 setValidationError(error instanceof Error ? error.message : "Failed to save action.");
242 return;
243 }
244
245 const result = editingScriptId
246 ? await onUpdateScript(editingScriptId, payload)
247 : await onAddScript(payload);
248 if (result._tag === "Failure") {
249 if (!isAtomCommandInterrupted(result)) {
250 const error = squashAtomCommandFailure(result);
251 setValidationError(error instanceof Error ? error.message : "Failed to save action.");
252 }
253 return;
254 }
255 setDialogOpen(false);
256 setIconPickerOpen(false);
257 };
258
259 const openAddDialog = () => {
260 setEditingScriptId(null);
261 setName("");
262 setCommand("");
263 setIcon("play");
264 setIconPickerOpen(false);
265 setRunOnWorktreeCreate(false);
266 setKeybinding("");
267 setPreviewUrl("");
268 setAutoOpenPreview(false);
269 setValidationError(null);
270 setDialogOpen(true);
271 };
272
273 const openEditDialog = (script: ProjectScript) => {
274 setEditingScriptId(script.id);
275 setName(script.name);
276 setCommand(script.command);
277 setIcon(script.icon);
278 setIconPickerOpen(false);
279 setRunOnWorktreeCreate(script.runOnWorktreeCreate);
280 setKeybinding(keybindingValueForCommand(keybindings, commandForProjectScript(script.id)) ?? "");
281 setPreviewUrl(script.previewUrl ?? "");
282 setAutoOpenPreview(script.autoOpenPreview ?? false);
283 setValidationError(null);
284 setDialogOpen(true);
285 };
286
287 const confirmDeleteScript = useCallback(() => {
288 if (!editingScriptId) return;
289 setDeleteConfirmOpen(false);
290 setDialogOpen(false);
291 void onDeleteScript(editingScriptId);
292 }, [editingScriptId, onDeleteScript]);
293
294 const importFileScript = async (fileScript: T3ProjectFileScript) => {
295 const payload: NewProjectScriptInput = {
296 name: fileScript.name,
297 command: fileScript.command,
298 icon: fileScript.icon ?? "play",
299 runOnWorktreeCreate: fileScript.runOnWorktreeCreate ?? false,
300 keybinding: null,
301 previewUrl: fileScript.previewUrl ?? null,
302 autoOpenPreview: fileScript.previewUrl ? (fileScript.autoOpenPreview ?? false) : false,
303 };
304 const result = await onAddScript(payload);
305 if (result._tag === "Failure" && !isAtomCommandInterrupted(result)) {
306 // Surface the failure through the regular add dialog, prefilled so the
307 // user can adjust and retry.
308 const error = squashAtomCommandFailure(result);
309 setEditingScriptId(null);
310 setName(payload.name);
311 setCommand(payload.command);
312 setIcon(payload.icon);
313 setIconPickerOpen(false);
314 setRunOnWorktreeCreate(payload.runOnWorktreeCreate);
315 setKeybinding("");
316 setPreviewUrl(payload.previewUrl ?? "");
317 setAutoOpenPreview(payload.autoOpenPreview);
318 setValidationError(error instanceof Error ? error.message : "Failed to import action.");
319 setDialogOpen(true);
320 }
321 };
322
323 const importMenuItems = importableScripts.length > 0 && (
324 <>
325 {primaryScript && <MenuSeparator />}
326 <MenuGroup>
327 <MenuGroupLabel>From t3.json</MenuGroupLabel>
328 {importableScripts.map((fileScript) => (
329 <MenuItem
330 key={`${fileScript.name} ${fileScript.command}`}
331 className={dropdownItemClassName}
332 onClick={() => void importFileScript(fileScript)}
333 >
334 <ScriptIcon icon={fileScript.icon ?? "play"} className="size-4" />
335 <span className="truncate">{fileScript.name}</span>
336 <MenuShortcut className="ms-auto">
337 <DownloadIcon className="size-3.5" aria-label="Import" />
338 </MenuShortcut>
339 </MenuItem>
340 ))}
341 </MenuGroup>
342 </>
343 );
344
345 return (
346 <>
347 {primaryScript ? (
348 <ActionGroup
349 role="group"
350 aria-label="Project scripts"
351 {...(isPanel
352 ? { className: THREAD_DETAILS_PANEL_SPLIT_GROUP_CLASS, ref: panelAnchorRef }
353 : {})}
354 >
355 <Tooltip>
356 <TooltipTrigger
357 render={
358 <Button
359 size="xs"
360 variant={isPanel ? "ghost" : "outline"}
361 className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_PRIMARY_CLASS : undefined}
362 aria-label={`Run ${primaryScript.name}`}
363 onClick={() => onRunScript(primaryScript)}
364 />
365 }
366 >
367 <ScriptIcon
368 icon={primaryScript.icon}
369 {...(isPanel ? { className: THREAD_DETAILS_PANEL_ICON_CLASS } : {})}
370 />
371 <span
372 className={cn(
373 "sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
374 isPanel && "not-sr-only ml-0.5 truncate",
375 )}
376 >
377 {primaryScript.name}
378 </span>
379 </TooltipTrigger>
380 <TooltipPopup side="top">Run {primaryScript.name}</TooltipPopup>
381 </Tooltip>
382 {isPanel ? (
383 <span aria-hidden="true" className={THREAD_DETAILS_PANEL_SPLIT_SEPARATOR_CLASS} />
384 ) : (
385 <GroupSeparator className="hidden @3xl/header-actions:block" />
386 )}
387 <Menu highlightItemOnHover={false}>
388 <MenuTrigger
389 render={
390 <Button
391 size={isPanel ? "sm" : "icon-xs"}
392 variant={isPanel ? "ghost" : "outline"}
393 className={isPanel ? THREAD_DETAILS_PANEL_SPLIT_SECONDARY_CLASS : undefined}
394 aria-label="Script actions"
395 />
396 }
397 >
398 <ChevronDownIcon
399 className={isPanel ? THREAD_DETAILS_PANEL_CHEVRON_CLASS : "size-4"}
400 />
401 </MenuTrigger>
402 <MenuPopup
403 align="end"
404 {...(isPanel ? { anchor: panelAnchorRef } : {})}
405 className={isPanel ? THREAD_DETAILS_PANEL_ROW_POPUP_CLASS : undefined}
406 >
407 {scripts.map((script) => {
408 const shortcutLabel = shortcutLabelForCommand(
409 keybindings,
410 commandForProjectScript(script.id),
411 );
412 return (
413 <MenuItem
414 key={script.id}
415 className={`group ${dropdownItemClassName}`}
416 onClick={() => onRunScript(script)}
417 >
418 <ScriptIcon icon={script.icon} className="size-4" />
419 <span className="truncate">
420 {script.runOnWorktreeCreate ? `${script.name} (setup)` : script.name}
421 </span>
422 <span className="relative ms-auto flex h-6 min-w-6 items-center justify-end">
423 {shortcutLabel && (
424 <MenuShortcut className="ms-0 transition-opacity group-hover:opacity-0 group-focus-visible:opacity-0">
425 {shortcutLabel}
426 </MenuShortcut>
427 )}
428 <Button
429 type="button"
430 variant="ghost"
431 size="icon-xs"
432 className="absolute right-0 top-1/2 size-6 -translate-y-1/2 opacity-0 pointer-events-none transition-opacity group-hover:opacity-100 group-hover:pointer-events-auto group-focus-visible:opacity-100 group-focus-visible:pointer-events-auto"
433 aria-label={`Edit ${script.name}`}
434 onPointerDown={(event) => {
435 event.preventDefault();
436 event.stopPropagation();
437 }}
438 onClick={(event) => {
439 event.preventDefault();
440 event.stopPropagation();
441 openEditDialog(script);
442 }}
443 >
444 <SettingsIcon className="size-3.5" />
445 </Button>
446 </span>
447 </MenuItem>
448 );
449 })}
450 {importMenuItems}
451 <MenuItem className={dropdownItemClassName} onClick={openAddDialog}>
452 <PlusIcon className="size-4" />
453 {isPanel ? "Add project script" : "Add action"}
454 </MenuItem>
455 </MenuPopup>
456 </Menu>
457 </ActionGroup>
458 ) : importableScripts.length > 0 ? (
459 <Menu highlightItemOnHover={false}>
460 <MenuTrigger render={<Button size="xs" variant="outline" aria-label="Project actions" />}>
461 <PlusIcon className="size-3.5" />
462 <span className="sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5">
463 Add action
464 </span>
465 <ChevronDownIcon className="size-3.5" />
466 </MenuTrigger>
467 <MenuPopup align="end">
468 {importMenuItems}
469 <MenuItem className={dropdownItemClassName} onClick={openAddDialog}>
470 <PlusIcon className="size-4" />
471 Add action
472 </MenuItem>
473 </MenuPopup>
474 </Menu>
475 ) : (
476 <Tooltip>
477 <TooltipTrigger
478 render={
479 <Button
480 size="xs"
481 variant={isPanel ? "ghost" : "outline"}
482 className={isPanel ? THREAD_DETAILS_PANEL_ROW_CLASS : undefined}
483 aria-label={isPanel ? "Add project script" : "Add action"}
484 onClick={openAddDialog}
485 />
486 }
487 >
488 <PlusIcon className="size-3.5" />
489 <span
490 className={cn(
491 "sr-only @3xl/header-actions:not-sr-only @3xl/header-actions:ml-0.5",
492 isPanel && "not-sr-only ml-0.5",
493 )}
494 >
495 {isPanel ? "Add project script" : "Add action"}
496 </span>
497 </TooltipTrigger>
498 <TooltipPopup side="top">{isPanel ? "Add project script" : "Add action"}</TooltipPopup>
499 </Tooltip>
500 )}
501
502 <Dialog
503 onOpenChange={(open) => {
504 setDialogOpen(open);
505 if (!open) {
506 setIconPickerOpen(false);
507 }
508 }}
509 onOpenChangeComplete={(open) => {
510 if (open) return;
511 setEditingScriptId(null);
512 setName("");
513 setCommand("");
514 setIcon("play");
515 setRunOnWorktreeCreate(false);
516 setKeybinding("");
517 setPreviewUrl("");
518 setAutoOpenPreview(false);
519 setValidationError(null);
520 }}
521 open={dialogOpen}
522 >
523 <DialogPopup>
524 <DialogHeader>
525 <DialogTitle>{isEditing ? "Edit Action" : "Add Action"}</DialogTitle>
526 <DialogDescription>
527 Actions are project-scoped commands you can run from the top bar or keybindings.
528 </DialogDescription>
529 </DialogHeader>
530 <DialogPanel>
531 <form id={addScriptFormId} className="space-y-4" onSubmit={submitAddScript}>
532 <div className="space-y-1.5">
533 <Label htmlFor="script-name">Name</Label>
534 <div className="flex items-center gap-2">
535 <Popover onOpenChange={setIconPickerOpen} open={iconPickerOpen}>
536 <PopoverTrigger
537 render={
538 <Button
539 type="button"
540 variant="outline"
541 className="size-9 shrink-0 hover:bg-popover active:bg-popover data-pressed:bg-popover data-pressed:shadow-xs/5 data-pressed:before:shadow-[0_1px_--theme(--color-black/4%)] dark:border-transparent dark:bg-white/[0.035] dark:data-pressed:before:shadow-none"
542 aria-label="Choose icon"
543 />
544 }
545 >
546 <ScriptIcon icon={icon} className="size-4.5" />
547 </PopoverTrigger>
548 <PopoverPopup align="start">
549 <div className="grid grid-cols-3 gap-2">
550 {SCRIPT_ICONS.map((entry) => {
551 const isSelected = entry.id === icon;
552 return (
553 <button
554 key={entry.id}
555 type="button"
556 className={`relative flex flex-col items-center gap-2 rounded-md border px-2 py-2 text-xs dark:border-transparent ${
557 isSelected
558 ? "border-primary/70 bg-primary/10 dark:ring-1 dark:ring-primary/30"
559 : "border-border/70 hover:bg-accent/60 dark:bg-white/[0.035]"
560 }`}
561 onClick={() => {
562 setIcon(entry.id);
563 setIconPickerOpen(false);
564 }}
565 >
566 <ScriptIcon icon={entry.id} className="size-4" />
567 <span>{entry.label}</span>
568 </button>
569 );
570 })}
571 </div>
572 </PopoverPopup>
573 </Popover>
574 <Input
575 id="script-name"
576 autoFocus
577 placeholder="Test"
578 value={name}
579 onChange={(event) => setName(event.target.value)}
580 />
581 </div>
582 </div>
583 <div className="space-y-1.5">
584 <Label htmlFor="script-keybinding">Keybinding</Label>
585 <Input
586 id="script-keybinding"
587 placeholder="Press shortcut"
588 value={keybinding}
589 readOnly
590 onKeyDown={captureKeybinding}
591 />
592 <p className="text-xs text-muted-foreground">
593 Press a shortcut. Use <code>Backspace</code> to clear.
594 </p>
595 </div>
596 <div className="space-y-1.5">
597 <Label htmlFor="script-command">Command</Label>
598 <Textarea
599 id="script-command"
600 placeholder="bun test"
601 value={command}
602 onChange={(event) => setCommand(event.target.value)}
603 />
604 </div>
605 <div className="space-y-1.5">
606 <Label htmlFor="script-preview-url">Preview URL (optional)</Label>
607 <Input
608 id="script-preview-url"
609 placeholder="http://localhost:5173"
610 value={previewUrl}
611 onChange={(event) => setPreviewUrl(event.target.value)}
612 />
613 <p className="text-xs text-muted-foreground">
614 Open this URL in the in-app preview when this action runs.
615 </p>
616 </div>
617 <label className="flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035]">
618 <span>Run automatically on worktree creation</span>
619 <Switch
620 checked={runOnWorktreeCreate}
621 onCheckedChange={(checked) => setRunOnWorktreeCreate(Boolean(checked))}
622 />
623 </label>
624 <label
625 className={`flex items-center justify-between gap-3 rounded-md border border-border/70 px-3 py-2 text-sm dark:border-transparent dark:bg-white/[0.035] ${
626 previewUrl.trim().length === 0 ? "opacity-60" : ""
627 }`}
628 >
629 <span>Open preview automatically when this action runs</span>
630 <Switch
631 checked={autoOpenPreview}
632 disabled={previewUrl.trim().length === 0}
633 onCheckedChange={(checked) => setAutoOpenPreview(Boolean(checked))}
634 />
635 </label>
636 {validationError && <p className="text-sm text-destructive">{validationError}</p>}
637 </form>
638 </DialogPanel>
639 <DialogFooter className="dark:border-transparent dark:bg-transparent">
640 {isEditing && (
641 <Button
642 type="button"
643 variant="destructive-outline"
644 className="mr-auto"
645 onClick={() => setDeleteConfirmOpen(true)}
646 >
647 Delete
648 </Button>
649 )}
650 <Button
651 type="button"
652 variant="outline"
653 onClick={() => {
654 setDialogOpen(false);
655 }}
656 >
657 Cancel
658 </Button>
659 <Button form={addScriptFormId} type="submit">
660 {isEditing ? "Save changes" : "Save action"}
661 </Button>
662 </DialogFooter>
663 </DialogPopup>
664 </Dialog>
665
666 <AlertDialog open={deleteConfirmOpen} onOpenChange={setDeleteConfirmOpen}>
667 <AlertDialogPopup>
668 <AlertDialogHeader>
669 <AlertDialogTitle>Delete action "{name}"?</AlertDialogTitle>
670 <AlertDialogDescription>This action cannot be undone.</AlertDialogDescription>
671 </AlertDialogHeader>
672 <AlertDialogFooter>
673 <AlertDialogClose render={<Button variant="outline" />}>Cancel</AlertDialogClose>
674 <Button variant="destructive" onClick={confirmDeleteScript}>
675 Delete action
676 </Button>
677 </AlertDialogFooter>
678 </AlertDialogPopup>
679 </AlertDialog>
680 </>
681 );
682}