From 2f6840fe3e302ed5bda8f997a125f5c2e09dd1b4 Mon Sep 17 00:00:00 2001
From: MechaCat02
Date: Thu, 28 May 2026 19:35:14 +0200
Subject: [PATCH] feat(dashboard): confirm modal for script delete
Replaces window.confirm + alert() with the in-dashboard ConfirmModal
(danger variant, name-retype). Body summarises what gets removed
(routes + execution logs) and embeds the API error inline rather than
firing a native alert.
Co-Authored-By: Claude Opus 4.7 (1M context)
---
.../src/routes/scripts/[id]/+page.svelte | 47 +++++++++++++++++--
1 file changed, 43 insertions(+), 4 deletions(-)
diff --git a/dashboard/src/routes/scripts/[id]/+page.svelte b/dashboard/src/routes/scripts/[id]/+page.svelte
index 75f5897..934933a 100644
--- a/dashboard/src/routes/scripts/[id]/+page.svelte
+++ b/dashboard/src/routes/scripts/[id]/+page.svelte
@@ -24,6 +24,7 @@
pathKindMismatchWarning
} from '$lib/route-utils';
import CodeEditor from '$lib/CodeEditor.svelte';
+ import ConfirmModal from '$lib/ConfirmModal.svelte';
import { format as formatRhai } from '$lib/rhai';
/// Pretty-print a JSON string in place, leaving it untouched if the
@@ -375,16 +376,25 @@
}
// ---------------- deletion ----------------
+ let confirmingDelete = $state(false);
let deleting = $state(false);
- async function remove() {
+ let deleteError = $state(null);
+
+ function askDelete() {
+ deleteError = null;
+ confirmingDelete = true;
+ }
+
+ async function confirmDelete() {
if (!script) return;
- if (!confirm(`Delete script "${script.name}"? This cannot be undone.`)) return;
deleting = true;
+ deleteError = null;
try {
await api.scripts.remove(id);
await goto(base + '/');
} catch (e) {
- alert(e instanceof Error ? e.message : String(e));
+ deleteError = e instanceof Error ? e.message : String(e);
+ } finally {
deleting = false;
}
}
@@ -429,7 +439,7 @@
{#if canAdmin}
-