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