Skip to content

armgit / dbx

Public Imported from GitHub
0

25 MB lightweight cross-platform database client for 100+ databases, including MySQL, PostgreSQL, SQLite, Redis, MongoDB, DuckDB, SQL Server, and Dameng. Built-in AI, MCP Server, CLI, desktop and Docker. | 轻量级跨平台数据库管理工具,支持 MySQL、PostgreSQL、SQLite、Redis、MongoDB、达梦等 100+ 数据库,提供桌面端、Docker、CLI、内置 AI 助手和 MCP。

feat(browsers): add database actions to database and table browsers

二丫讲梵720fad47e534
diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue
index 08c1298f80..1ade88c5d8 100644
--- a/apps/desktop/src/App.vue
+++ b/apps/desktop/src/App.vue
@@ -13,6 +13,7 @@ import AppToolbar from "@/components/layout/AppToolbar.vue";
import AppTabBar from "@/components/layout/AppTabBar.vue";
import { createGroupTabBarPortal, GROUP_TAB_BAR_PORTAL } from "@/components/layout/groupTabBarPortal";
import PluginShortcutBar from "@/components/plugins/PluginShortcutBar.vue";
+import SidebarDangerDialogHost from "@/components/sidebar/SidebarDangerDialogHost.vue";
import AppSidebar from "@/components/layout/AppSidebar.vue";
import SqlEditorWorkspace from "@/components/layout/SqlEditorWorkspace.vue";
import { EDITOR_TOOLBAR_ACTIONS } from "@/components/layout/editorToolbarActions";
@@ -4715,6 +4716,7 @@ onUnmounted(() => {
<div class="h-full w-full" :style="appBackgroundImageStyle"></div>
</div>
<TooltipProvider :delay-duration="300">
+ <SidebarDangerDialogHost />
<div data-app-shell class="h-screen w-screen max-w-full min-w-[760px] min-h-[600px] flex flex-col bg-background text-foreground overflow-hidden" :class="{ 'dbx-desktop-window-frame': drawDesktopWindowFrame }" :style="appUiFontFamilyStyle">
<AppToolbar
v-if="!isDetachedWindowContext"
diff --git a/apps/desktop/src/components/objects/DatabaseActionsMenu.vue b/apps/desktop/src/components/objects/DatabaseActionsMenu.vue
new file mode 100644
index 0000000000..e48e635e14
--- /dev/null
+++ b/apps/desktop/src/components/objects/DatabaseActionsMenu.vue
@@ -0,0 +1,59 @@
+<script setup lang="ts">
+import { computed, nextTick, ref } from "vue";
+import { MoreHorizontal } from "@lucide/vue";
+import { useI18n } from "vue-i18n";
+import { Button } from "@/components/ui/button";
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuLabel, DropdownMenuSeparator, DropdownMenuTrigger } from "@/components/ui/dropdown-menu";
+import type { ContextMenuItem } from "@/components/ui/customContextMenuRegistry";
+import SidebarTreeRuntimeHost from "@/components/sidebar/SidebarTreeRuntimeHost.vue";
+import { canEmptyDatabaseTables } from "@/composables/useDatabaseTableEmpty";
+import { canDropDatabaseNode } from "@/lib/database/databaseBrowserActions";
+import { openSidebarDangerDialog } from "@/lib/sidebar/sidebarDangerDialog";
+import type { ConnectionConfig, TreeNode } from "@/types/database";
+
+const props = defineProps<{ connection: ConnectionConfig; database: string; catalog?: string }>();
+const { t } = useI18n();
+const runtime = ref<InstanceType<typeof SidebarTreeRuntimeHost> | null>(null);
+const runtimeNode: TreeNode = { id: "__database-actions-runtime__", label: "", type: "connection-group" };
+const items = ref<ContextMenuItem[]>([]);
+const runtimeMounted = ref(false);
+const target = computed<TreeNode>(() => ({
+ id: `${props.connection.id}:${props.database}`,
+ label: props.database,
+ type: "database",
+ connectionId: props.connection.id,
+ database: props.database,
+}));
+// A catalog browser must not accidentally offer operations on the connection's database.
+const available = computed(() => !props.catalog && (canEmptyDatabaseTables(target.value, props.connection) || canDropDatabaseNode(target.value, props.connection)));
+
+async function onOpen(open: boolean) {
+ if (!open) return;
+ runtimeMounted.value = true;
+ await nextTick();
+ // Build only when opened: the runtime binds immutable targets to the actions.
+ const menu = runtime.value?.buildContextMenu(target.value) ?? [];
+ items.value = menu.find((item) => item.label === t("common.more"))?.children ?? [];
+}
+</script>
+
+<template>
+ <template v-if="available">
+ <DropdownMenu @update:open="onOpen">
+ <DropdownMenuTrigger as-child>
+ <Button variant="ghost" size="icon" class="h-7 w-7 shrink-0" :title="`${database} · ${t('common.more')}`" :aria-label="`${database} · ${t('common.more')}`">
+ <MoreHorizontal class="h-3.5 w-3.5" />
+ </Button>
+ </DropdownMenuTrigger>
+ <DropdownMenuContent align="start" class="w-56">
+ <DropdownMenuLabel class="truncate" :title="database">{{ database }}</DropdownMenuLabel>
+ <DropdownMenuSeparator />
+ <DropdownMenuItem v-for="item in items" :key="item.label" :disabled="typeof item.disabled === 'function' ? item.disabled() : item.disabled" variant="destructive" @select="item.action?.()">
+ <component :is="item.icon" v-if="item.icon" class="h-3.5 w-3.5" />
+ {{ item.label }}
+ </DropdownMenuItem>
+ </DropdownMenuContent>
+ </DropdownMenu>
+ <SidebarTreeRuntimeHost v-if="runtimeMounted" ref="runtime" :node="runtimeNode" :depth="0" @open-danger-dialog="openSidebarDangerDialog" />
+ </template>
+</template>
diff --git a/apps/desktop/src/components/objects/DatabaseBrowser.vue b/apps/desktop/src/components/objects/DatabaseBrowser.vue
index 52c4072a6e..4bcc6d0eba 100644
--- a/apps/desktop/src/components/objects/DatabaseBrowser.vue
+++ b/apps/desktop/src/components/objects/DatabaseBrowser.vue
@@ -7,6 +7,8 @@ import { DropdownMenuItem, DropdownMenuSeparator, DropdownMenuSub, DropdownMenuS
import { Input } from "@/components/ui/input";
import ToolbarOverflowMenu from "@/components/ui/ToolbarOverflowMenu.vue";
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
+import { openSidebarDangerDialog } from "@/lib/sidebar/sidebarDangerDialog";
+import { useDatabaseBrowserMutation } from "@/lib/database/databaseBrowserActions";
import SidebarTreeRuntimeHost from "@/components/sidebar/SidebarTreeRuntimeHost.vue";
import SidebarTreeItemDialogs from "@/components/sidebar/SidebarTreeItemDialogs.vue";
import { useToolbarOverflow } from "@/composables/useToolbarOverflow";
@@ -161,12 +163,13 @@ function removeUnsupportedDatabaseItems(items: ContextMenuItem[]): ContextMenuIt
// visible-schemas item emits "open-visible-schemas" which only the sidebar
// tree handles. The database browser wires neither, so do not expose menu
// items that would otherwise be a silent no-op here.
- return items.flatMap((item) => {
- if (item.label.startsWith(t("contextMenu.addToAi")) || item.label === t("visibleSchemas.title") || item.variant === "destructive") return [];
+ const supported = items.flatMap((item) => {
+ if (item.label.startsWith(t("contextMenu.addToAi")) || item.label === t("visibleSchemas.title")) return [];
if (!item.children) return [item];
const children = removeUnsupportedDatabaseItems(item.children);
return children.length ? [{ ...item, children }] : [];
});
+ return supported.filter((item, index) => !item.separator || (index > 0 && index < supported.length - 1 && !supported[index - 1]?.separator));
}
function openDatabaseFromSidebar(node: TreeNode) {
@@ -342,6 +345,10 @@ watch(
{ immediate: true },
);
+useDatabaseBrowserMutation(({ connectionId }) => {
+ if (connectionId === props.connection.id) void refresh();
+});
+
onBeforeUnmount(() => stopColumnResize?.());
defineExpose({ focusSearch, refresh });
@@ -485,7 +492,7 @@ defineExpose({ focusSearch, refresh });
</div>
</div>
</div>
- <SidebarTreeRuntimeHost ref="sidebarRuntimeHost" :node="sidebarRuntimeNode" :depth="0" @open-data="openDatabaseFromSidebar" @open-ddl="openDatabaseFromSidebar" @open-dialog-controller="sidebarDialogController = $event" />
+ <SidebarTreeRuntimeHost ref="sidebarRuntimeHost" :node="sidebarRuntimeNode" :depth="0" @open-danger-dialog="openSidebarDangerDialog" @open-data="openDatabaseFromSidebar" @open-ddl="openDatabaseFromSidebar" @open-dialog-controller="sidebarDialogController = $event" />
<SidebarTreeItemDialogs v-if="sidebarDialogController" :controller="sidebarDialogController" @closed="sidebarDialogController = null" />
</section>
</template>
diff --git a/apps/desktop/src/components/objects/ObjectBrowser.vue b/apps/desktop/src/components/objects/ObjectBrowser.vue
index 2fb11c9292..b751f05442 100644
--- a/apps/desktop/src/components/objects/ObjectBrowser.vue
+++ b/apps/desktop/src/components/objects/ObjectBrowser.vue
@@ -1,5 +1,7 @@
<script setup lang="ts">
import { applyDdlStoragePreference } from "@/lib/sql/ddlStorage";
+import DatabaseActionsMenu from "@/components/objects/DatabaseActionsMenu.vue";
+import { useDatabaseBrowserMutation } from "@/lib/database/databaseBrowserActions";
import DdlStorageToggle from "@/components/objects/DdlStorageToggle.vue";
import { computed, createApp, nextTick, onActivated, onBeforeUnmount, ref, watch, type Component } from "vue";
@@ -3423,6 +3425,10 @@ async function reload(options?: { allowCachedObjects?: boolean; contextEpoch?: n
await loadObjects({ allowCached: options?.allowCachedObjects, preserveExistingRows: options?.preserveExistingRows });
}
+useDatabaseBrowserMutation(({ connectionId, database, operation }) => {
+ if (connectionId === props.connection.id && database === props.database && !props.catalog && operation !== "drop-database") refresh();
+});
+
function refresh(): boolean {
void reload({ preserveExistingRows: true });
void refreshActiveTableInfo();
@@ -3830,6 +3836,7 @@ function getObjectBrowserMenuItems(item: ObjectBrowserRow): ContextMenuItem[] {
<span v-if="selectedSchema && showDatabaseChip" class="inline-flex max-w-[14rem] min-w-0 items-center rounded border border-border bg-muted/30 px-2 py-0.5 text-xs text-muted-foreground truncate" :title="props.database">
{{ props.database }}
</span>
+ <DatabaseActionsMenu :connection="connection" :database="database" :catalog="catalog" />
</div>
<div class="flex flex-1 items-center gap-2">
<div class="relative min-w-[6rem] flex-1">
diff --git a/apps/desktop/src/components/objects/__tests__/DatabaseActionsMenu.component.spec.ts b/apps/desktop/src/components/objects/__tests__/DatabaseActionsMenu.component.spec.ts
new file mode 100644
index 0000000000..4745f5d76f
--- /dev/null
+++ b/apps/desktop/src/components/objects/__tests__/DatabaseActionsMenu.component.spec.ts
@@ -0,0 +1,75 @@
+// @vitest-environment happy-dom
+
+import { createApp, defineComponent, h, nextTick, type App } from "vue";
+import { afterEach, expect, it, vi } from "vitest";
+import DatabaseActionsMenu from "../DatabaseActionsMenu.vue";
+import type { ConnectionConfig } from "@/types/database";
+
+const mocks = vi.hoisted(() => ({ mounted: vi.fn(), build: vi.fn(), action: vi.fn() }));
+vi.mock("vue-i18n", async (importOriginal) => ({ ...(await importOriginal<typeof import("vue-i18n")>()), useI18n: () => ({ t: (key: string) => key }) }));
+vi.mock("@/components/sidebar/SidebarTreeRuntimeHost.vue", () => ({
+ default: defineComponent({
+ setup(_, { expose }) {
+ mocks.mounted();
+ expose({ buildContextMenu: mocks.build });
+ return () => null;
+ },
+ }),
+}));
+vi.mock("@/components/ui/dropdown-menu", () => {
+ const passthrough = defineComponent({
+ setup:
+ (_, { slots }) =>
+ () =>
+ h("div", slots.default?.()),
+ });
+ return {
+ DropdownMenu: defineComponent({
+ emits: ["update:open"],
+ setup:
+ (_, { slots, emit }) =>
+ () =>
+ h("div", [h("button", { "data-open": "", onClick: () => emit("update:open", true) }, "open"), slots.default?.()]),
+ }),
+ DropdownMenuContent: passthrough,
+ DropdownMenuLabel: passthrough,
+ DropdownMenuSeparator: passthrough,
+ DropdownMenuTrigger: passthrough,
+ DropdownMenuItem: defineComponent({
+ emits: ["select"],
+ setup:
+ (_, { slots, emit }) =>
+ () =>
+ h("button", { "data-action": "", onClick: () => emit("select") }, slots.default?.()),
+ }),
+ };
+});
+
+let app: App | undefined;
+afterEach(() => {
+ app?.unmount();
+ document.body.innerHTML = "";
+ vi.clearAllMocks();
+});
+
+it("mounts the runtime only on demand and makes actions available on the first opening", async () => {
+ mocks.build.mockReturnValue([{ label: "common.more", children: [{ label: "databaseDrop.menu", action: mocks.action }] }]);
+ const root = document.createElement("div");
+ document.body.appendChild(root);
+ app = createApp(DatabaseActionsMenu, { connection: { id: "mysql-1", db_type: "mysql" } as ConnectionConfig, database: "app" });
+ app.mount(root);
+ await nextTick();
+ expect(mocks.mounted).not.toHaveBeenCalled();
+ root.querySelector<HTMLButtonElement>("[data-open]")!.click();
+ await nextTick();
+ await nextTick();
+ expect(mocks.mounted).toHaveBeenCalledTimes(1);
+ expect(mocks.build).toHaveBeenCalledWith(expect.objectContaining({ connectionId: "mysql-1", database: "app", type: "database" }));
+ const action = root.querySelector<HTMLButtonElement>("[data-action]")!;
+ expect(action.textContent).toContain("databaseDrop.menu");
+ action.click();
+ expect(mocks.action).toHaveBeenCalledTimes(1);
+ root.querySelector<HTMLButtonElement>("[data-open]")!.click();
+ await nextTick();
+ expect(mocks.mounted).toHaveBeenCalledTimes(1);
+});
diff --git a/apps/desktop/src/components/sidebar/ConnectionTree.vue b/apps/desktop/src/components/sidebar/ConnectionTree.vue
index 03678355dc..00be120ff3 100644
--- a/apps/desktop/src/components/sidebar/ConnectionTree.vue
+++ b/apps/desktop/src/components/sidebar/ConnectionTree.vue
@@ -79,15 +79,14 @@ import { Switch } from "@/components/ui/switch";
import { cancelPendingSidebarDataOpen, runSidebarDataOpenImmediately, type SidebarDataOpenRequest } from "@/lib/sidebar/sidebarDataOpenCoordinator";
import CustomContextMenu, { type ContextMenuItem } from "@/components/ui/CustomContextMenu.vue";
import { Button } from "@/components/ui/button";
-import { Input } from "@/components/ui/input";
import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle } from "@/components/ui/dialog";
import { codeMirrorSqlDialect } from "@/lib/database/jdbcDialect";
import { sqlFormatDialectForDbType } from "@/lib/sql/sqlFormatter";
import { createSidebarActionTarget, findSidebarActionTarget, matchesSidebarActionTarget, type SidebarActionTarget } from "@/lib/sidebar/sidebarActionTarget";
import { syncSidebarTreeNodeExpansion } from "@/lib/sidebar/sidebarTreeExpansion";
-import type { SidebarDangerDialogOption, SidebarDangerDialogRequest } from "@/lib/sidebar/sidebarDangerDialog";
-import { resetSidebarTreeDialogState, sidebarDangerRunningExecutionId } from "./sidebarTreeDialogState";
-import { SidebarDangerConfirmDialog, SidebarDdlViewDialog, SidebarElasticsearchIndexMetadataDialog, SidebarObjectSourceDialog, SidebarProcedureExecutionDialog, SidebarVisibleDatabasesDialog, SidebarVisibleNacosNamespacesDialog, SidebarVisibleSchemasDialog } from "./sidebarAsyncDialogs";
+import { openSidebarDangerDialog } from "@/lib/sidebar/sidebarDangerDialog";
+import { resetSidebarTreeDialogState } from "./sidebarTreeDialogState";
+import { SidebarDdlViewDialog, SidebarElasticsearchIndexMetadataDialog, SidebarObjectSourceDialog, SidebarProcedureExecutionDialog, SidebarVisibleDatabasesDialog, SidebarVisibleNacosNamespacesDialog, SidebarVisibleSchemasDialog } from "./sidebarAsyncDialogs";
import { sortConnectionListForDisplay } from "@/lib/sidebar/connectionListSort";
import { sidebarDisplayTableName } from "@/lib/sidebar/sidebarTableNameDisplay";
import { alignedSidebarCommentLabelWidths, isSidebarCommentAlignableNode, sidebarTreeNaturalContentWidth, sidebarTreeNodeComment, usesFullWidthTreeLabel } from "@/lib/sidebar/sidebarTreeItemLayout";
@@ -127,10 +126,6 @@ const emit = defineEmits<{
}>();
const sidebarContextMenuTarget = ref<SidebarActionTarget | null>(null);
-const sidebarDangerDialogRequest = ref<SidebarDangerDialogRequest | null>(null);
-const sidebarDangerDialogOpen = ref(false);
-const sidebarDangerDialogConfirming = ref(false);
-const sidebarDangerDialogCancelling = ref(false);
const sidebarTreeItemDialogController = ref<Record<string, any> | null>(null);
const sidebarInstallExtensionTarget = ref<TreeNode | null>(null);
const sidebarInstallExtensionDialogRef = ref<InstanceType<typeof InstallExtensionDialog> | null>(null);
@@ -1971,83 +1966,6 @@ function openSidebarContextMenu(event: MouseEvent, node: TreeNode, openContextMe
} else show(resolved);
}
-function openSidebarDangerDialog(request: SidebarDangerDialogRequest) {
- if (sidebarDangerRunningExecutionId.value) {
- toast(t("contextMenu.dangerOperationAlreadyRunning"), 4000);
- return;
- }
- sidebarDangerDialogRequest.value = request;
- sidebarDangerDialogConfirming.value = false;
- // Defense in depth: sidebarDangerDialogCancelling is a singleton shared
- // across every danger dialog. It should already settle on its own (see
- // confirmCancelWithRetryAndTimeout), but a fresh dialog must never inherit
- // a stuck "cancelling" state from a previous one.
- sidebarDangerDialogCancelling.value = false;
- sidebarDangerDialogOpen.value = true;
-}
-
-async function confirmSidebarDangerDialog() {
- const request = sidebarDangerDialogRequest.value;
- if (!request || sidebarDangerDialogConfirming.value) return;
- if (request.closeOnConfirm !== false) sidebarDangerDialogOpen.value = false;
- sidebarDangerDialogConfirming.value = true;
- let completed: void | boolean = undefined;
- try {
- completed = await request.confirm();
- } finally {
- // A danger operation that hit a client-observed timeout is kept alive
- // (still cancellable) rather than settled outright — sidebarDangerRunningExecutionId
- // stays populated in that case, so keep the dialog "loading" (Cancel
- // Query still live, manual dismiss blocked) instead of closing on a
- // stale timeout result. The watcher below finishes the job once the
- // execution actually settles.
- if (!sidebarDangerRunningExecutionId.value) {
- sidebarDangerDialogConfirming.value = false;
- if (completed !== false) sidebarDangerDialogOpen.value = false;
- }
- }
-}
-
-// Finishes closing a danger dialog left open past a client-observed timeout
-// once the deferred execution is actually confirmed cancelled — see
-// confirmSidebarDangerDialog above.
-watch(sidebarDangerRunningExecutionId, (value) => {
- if (!value && sidebarDangerDialogConfirming.value) {
- sidebarDangerDialogConfirming.value = false;
- sidebarDangerDialogOpen.value = false;
- }
-});
-
-async function cancelSidebarDangerDialogRunning() {
- const request = sidebarDangerDialogRequest.value;
- if (!request?.cancelRunning || sidebarDangerDialogCancelling.value) return;
- sidebarDangerDialogCancelling.value = true;
- try {
- await request.cancelRunning();
- } catch (error: any) {
- // Current cancelRunning implementations already swallow their own
- // rejections; this is a defensive fallback so the user still gets
- // feedback if a future implementation throws instead.
- toast(t("contextMenu.tableOperationFailed", { message: error?.message || String(error) }), 5000);
- } finally {
- sidebarDangerDialogCancelling.value = false;
- }
-}
-
-function updateSidebarDangerDialogOption(event: Event, optionOverride?: SidebarDangerDialogOption) {
- const option = optionOverride ?? sidebarDangerDialogRequest.value?.option;
- if (!option) return;
- option.checked = (event.target as HTMLInputElement).checked;
- void option.onChange?.(option.checked);
-}
-
-function updateSidebarDangerDialogTextInput(value: string | number) {
- const input = sidebarDangerDialogRequest.value?.textInput;
- if (!input) return;
- input.value = String(value);
- void input.onInput?.(input.value);
-}
-
function updateSidebarTreeItemDialogController(controller: Record<string, any> | null) {
sidebarTreeItemDialogController.value = controller;
}
@@ -2584,7 +2502,6 @@ onUnmounted(() => {
sidebarVisibleSchemasTarget.value = null;
sidebarVisibleNacosNamespacesTarget.value = null;
sidebarTreeItemDialogController.value = null;
- sidebarDangerDialogRequest.value = null;
resetSidebarTreeDialogState();
window.removeEventListener("keydown", onWindowKeydown);
cancelPendingSidebarDataOpen();
@@ -2915,58 +2832,6 @@ defineExpose({ focusSearch, createNewGroup, collapseAllTreeNodes, locateTabInSid
</DialogFooter>
</DialogContent>
</Dialog>
- <SidebarDangerConfirmDialog
- v-if="sidebarDangerDialogRequest"
- v-model:open="sidebarDangerDialogOpen"
- :title="sidebarDangerDialogRequest.title"
- :message="sidebarDangerDialogRequest.message"
- :sql="sidebarDangerDialogRequest.sql"
- :copy-sql="sidebarDangerDialogRequest.copySql"
- :details="sidebarDangerDialogRequest.details"
- :details-text="sidebarDangerDialogRequest.detailsText"
- :confirm-label="sidebarDangerDialogRequest.confirmLabel"
- :loading="sidebarDangerDialogConfirming || sidebarDangerDialogRequest.loading"
- :confirm-disabled="sidebarDangerDialogRequest.confirmDisabled"
- :close-on-confirm="false"
- :cancelable="!!sidebarDangerDialogRequest.cancelRunning"
- :cancel-running-loading="sidebarDangerDialogCancelling"
- @confirm="confirmSidebarDangerDialog"
- @cancel-running="cancelSidebarDangerDialogRunning"
- >
- <template #options>
- <div v-if="sidebarDangerDialogRequest.progress" class="mb-3 rounded-md border bg-muted/20 px-3 py-2.5">
- <div class="mb-1.5 flex items-center justify-between text-xs tabular-nums text-muted-foreground">
- <span>{{ sidebarDangerDialogRequest.progress.phase === "preparing" ? t("databaseEmpty.preparing", { database: sidebarDangerDialogRequest.target.database }) : "" }} {{ sidebarDangerDialogRequest.progress.completed }} / {{ sidebarDangerDialogRequest.progress.total }}</span>
- <span>{{ Math.round((sidebarDangerDialogRequest.progress.completed / sidebarDangerDialogRequest.progress.total) * 100) }}%</span>
- </div>
- <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" :aria-valuemin="0" :aria-valuemax="sidebarDangerDialogRequest.progress.total" :aria-valuenow="sidebarDangerDialogRequest.progress.completed">
- <div class="h-full bg-primary transition-[width] duration-200" :style="{ width: `${Math.round((sidebarDangerDialogRequest.progress.completed / sidebarDangerDialogRequest.progress.total) * 100)}%` }" />
- </div>
- </div>
- <div v-if="sidebarDangerDialogRequest.options?.length" class="mb-3 flex flex-wrap gap-2">
- <template v-for="(option, optionIndex) in sidebarDangerDialogRequest.options ?? []" :key="`danger-option-${optionIndex}`">
- <label class="flex items-start gap-2 rounded-md border px-3 py-2 text-sm" :class="[option.compact ? 'min-w-32 flex-1' : 'w-full', option.danger && option.checked ? 'border-destructive/50 bg-destructive/10' : 'bg-muted/20']" :title="option.compact ? option.hint : undefined">
- <input :checked="option.checked" :disabled="sidebarDangerDialogConfirming" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0" :class="option.danger ? 'accent-destructive' : 'accent-primary'" @change="updateSidebarDangerDialogOption($event, option)" />
- <span class="grid gap-0.5">
- <span class="font-medium" :class="option.danger && option.checked ? 'text-destructive' : 'text-foreground'">{{ option.label }}</span>
- <span v-if="!option.compact" class="text-xs leading-5 text-muted-foreground">{{ option.hint }}</span>
- </span>
- </label>
- </template>
- </div>
- <label v-if="sidebarDangerDialogRequest.option" class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">
- <input :checked="sidebarDangerDialogRequest.option.checked" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="updateSidebarDangerDialogOption" />
- <span class="grid gap-0.5">
- <span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.option.label }}</span>
- <span class="text-xs leading-5 text-muted-foreground">{{ sidebarDangerDialogRequest.option.hint }}</span>
- </span>
- </label>
- <label v-if="sidebarDangerDialogRequest.textInput" class="mb-3 grid gap-1.5 rounded-md border bg-muted/20 px-3 py-2 text-sm">
- <span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.textInput.label }}</span>
- <Input :model-value="sidebarDangerDialogRequest.textInput.value" :inputmode="sidebarDangerDialogRequest.textInput.inputMode" :placeholder="sidebarDangerDialogRequest.textInput.placeholder" @update:model-value="updateSidebarDangerDialogTextInput" />
- </label>
- </template>
- </SidebarDangerConfirmDialog>
<SidebarTreeItemDialogs v-if="sidebarTreeItemDialogController" :key="sidebarTreeItemDialogController.node?.id" :controller="sidebarTreeItemDialogController" @closed="sidebarTreeItemDialogController = null" />
<SidebarTableVGroupDialog @created="focusCreatedTableVGroup" />
<InstallExtensionDialog v-if="sidebarInstallExtensionTarget" ref="sidebarInstallExtensionDialogRef" :node="sidebarInstallExtensionTarget" @close="refreshSidebarActionTarget" @changed="refreshSidebarActionTarget" />
diff --git a/apps/desktop/src/components/sidebar/SidebarDangerDialogHost.vue b/apps/desktop/src/components/sidebar/SidebarDangerDialogHost.vue
new file mode 100644
index 0000000000..1949670951
--- /dev/null
+++ b/apps/desktop/src/components/sidebar/SidebarDangerDialogHost.vue
@@ -0,0 +1,151 @@
+<script setup lang="ts">
+import { onBeforeUnmount, ref, watch } from "vue";
+import { useI18n } from "vue-i18n";
+import { Input } from "@/components/ui/input";
+import { useToast } from "@/composables/useToast";
+import { SidebarDangerConfirmDialog } from "./sidebarAsyncDialogs";
+import { sidebarDangerRunningExecutionId } from "./sidebarTreeDialogState";
+import { registerSidebarDangerDialogHost, type SidebarDangerDialogOption, type SidebarDangerDialogRequest } from "@/lib/sidebar/sidebarDangerDialog";
+
+const { t } = useI18n();
+const { toast } = useToast();
+const sidebarDangerDialogRequest = ref<SidebarDangerDialogRequest | null>(null);
+const sidebarDangerDialogOpen = ref(false);
+const sidebarDangerDialogConfirming = ref(false);
+const sidebarDangerDialogCancelling = ref(false);
+
+function showSidebarDangerDialog(request: SidebarDangerDialogRequest) {
+ if (sidebarDangerRunningExecutionId.value || sidebarDangerDialogConfirming.value || (sidebarDangerDialogOpen.value && sidebarDangerDialogRequest.value?.loading)) {
+ toast(t("contextMenu.dangerOperationAlreadyRunning"), 4000);
+ return;
+ }
+ sidebarDangerDialogRequest.value = request;
+ sidebarDangerDialogConfirming.value = false;
+ // Defense in depth: sidebarDangerDialogCancelling is a singleton shared
+ // across every danger dialog. It should already settle on its own (see
+ // confirmCancelWithRetryAndTimeout), but a fresh dialog must never inherit
+ // a stuck "cancelling" state from a previous one.
+ sidebarDangerDialogCancelling.value = false;
+ sidebarDangerDialogOpen.value = true;
+}
+
+async function confirmSidebarDangerDialog() {
+ const request = sidebarDangerDialogRequest.value;
+ if (!request || sidebarDangerDialogConfirming.value) return;
+ if (request.closeOnConfirm !== false) sidebarDangerDialogOpen.value = false;
+ sidebarDangerDialogConfirming.value = true;
+ let completed: void | boolean = undefined;
+ try {
+ completed = await request.confirm();
+ } finally {
+ // A danger operation that hit a client-observed timeout is kept alive
+ // (still cancellable) rather than settled outright — sidebarDangerRunningExecutionId
+ // stays populated in that case, so keep the dialog "loading" (Cancel
+ // Query still live, manual dismiss blocked) instead of closing on a
+ // stale timeout result. The watcher below finishes the job once the
+ // execution actually settles.
+ if (!sidebarDangerRunningExecutionId.value) {
+ sidebarDangerDialogConfirming.value = false;
+ if (completed !== false) sidebarDangerDialogOpen.value = false;
+ }
+ }
+}
+
+// Finishes closing a danger dialog left open past a client-observed timeout
+// once the deferred execution is actually confirmed cancelled — see
+// confirmSidebarDangerDialog above.
+watch(sidebarDangerRunningExecutionId, (value) => {
+ if (!value && sidebarDangerDialogConfirming.value) {
+ sidebarDangerDialogConfirming.value = false;
+ sidebarDangerDialogOpen.value = false;
+ }
+});
+
+async function cancelSidebarDangerDialogRunning() {
+ const request = sidebarDangerDialogRequest.value;
+ if (!request?.cancelRunning || sidebarDangerDialogCancelling.value) return;
+ sidebarDangerDialogCancelling.value = true;
+ try {
+ await request.cancelRunning();
+ } catch (error: any) {
+ // Current cancelRunning implementations already swallow their own
+ // rejections; this is a defensive fallback so the user still gets
+ // feedback if a future implementation throws instead.
+ toast(t("contextMenu.tableOperationFailed", { message: error?.message || String(error) }), 5000);
+ } finally {
+ sidebarDangerDialogCancelling.value = false;
+ }
+}
+
+function updateSidebarDangerDialogOption(event: Event, optionOverride?: SidebarDangerDialogOption) {
+ const option = optionOverride ?? sidebarDangerDialogRequest.value?.option;
+ if (!option) return;
+ option.checked = (event.target as HTMLInputElement).checked;
+ void option.onChange?.(option.checked);
+}
+
+function updateSidebarDangerDialogTextInput(value: string | number) {
+ const input = sidebarDangerDialogRequest.value?.textInput;
+ if (!input) return;
+ input.value = String(value);
+ void input.onInput?.(input.value);
+}
+
+const unregister = registerSidebarDangerDialogHost(showSidebarDangerDialog);
+onBeforeUnmount(unregister);
+</script>
+
+<template>
+ <SidebarDangerConfirmDialog
+ v-if="sidebarDangerDialogRequest"
+ v-model:open="sidebarDangerDialogOpen"
+ :title="sidebarDangerDialogRequest.title"
+ :message="sidebarDangerDialogRequest.message"
+ :sql="sidebarDangerDialogRequest.sql"
+ :copy-sql="sidebarDangerDialogRequest.copySql"
+ :details="sidebarDangerDialogRequest.details"
+ :details-text="sidebarDangerDialogRequest.detailsText"
+ :confirm-label="sidebarDangerDialogRequest.confirmLabel"
+ :loading="sidebarDangerDialogConfirming || sidebarDangerDialogRequest.loading"
+ :confirm-disabled="sidebarDangerDialogRequest.confirmDisabled"
+ :close-on-confirm="false"
+ :cancelable="!!sidebarDangerDialogRequest.cancelRunning"
+ :cancel-running-loading="sidebarDangerDialogCancelling"
+ @confirm="confirmSidebarDangerDialog"
+ @cancel-running="cancelSidebarDangerDialogRunning"
+ >
+ <template #options>
+ <div v-if="sidebarDangerDialogRequest.progress" class="mb-3 rounded-md border bg-muted/20 px-3 py-2.5">
+ <div class="mb-1.5 flex items-center justify-between text-xs tabular-nums text-muted-foreground">
+ <span>{{ sidebarDangerDialogRequest.progress.phase === "preparing" ? t("databaseEmpty.preparing", { database: sidebarDangerDialogRequest.target.database }) : "" }} {{ sidebarDangerDialogRequest.progress.completed }} / {{ sidebarDangerDialogRequest.progress.total }}</span>
+ <span>{{ Math.round((sidebarDangerDialogRequest.progress.completed / sidebarDangerDialogRequest.progress.total) * 100) }}%</span>
+ </div>
+ <div class="h-2 overflow-hidden rounded-full bg-muted" role="progressbar" :aria-valuemin="0" :aria-valuemax="sidebarDangerDialogRequest.progress.total" :aria-valuenow="sidebarDangerDialogRequest.progress.completed">
+ <div class="h-full bg-primary transition-[width] duration-200" :style="{ width: `${Math.round((sidebarDangerDialogRequest.progress.completed / sidebarDangerDialogRequest.progress.total) * 100)}%` }" />
+ </div>
+ </div>
+ <div v-if="sidebarDangerDialogRequest.options?.length" class="mb-3 flex flex-wrap gap-2">
+ <template v-for="(option, optionIndex) in sidebarDangerDialogRequest.options ?? []" :key="`danger-option-${optionIndex}`">
+ <label class="flex items-start gap-2 rounded-md border px-3 py-2 text-sm" :class="[option.compact ? 'min-w-32 flex-1' : 'w-full', option.danger && option.checked ? 'border-destructive/50 bg-destructive/10' : 'bg-muted/20']" :title="option.compact ? option.hint : undefined">
+ <input :checked="option.checked" :disabled="sidebarDangerDialogConfirming" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0" :class="option.danger ? 'accent-destructive' : 'accent-primary'" @change="updateSidebarDangerDialogOption($event, option)" />
+ <span class="grid gap-0.5">
+ <span class="font-medium" :class="option.danger && option.checked ? 'text-destructive' : 'text-foreground'">{{ option.label }}</span>
+ <span v-if="!option.compact" class="text-xs leading-5 text-muted-foreground">{{ option.hint }}</span>
+ </span>
+ </label>
+ </template>
+ </div>
+ <label v-if="sidebarDangerDialogRequest.option" class="mb-3 flex items-start gap-2 rounded-md border bg-muted/20 px-3 py-2 text-sm">
+ <input :checked="sidebarDangerDialogRequest.option.checked" type="checkbox" class="mt-0.5 h-3.5 w-3.5 shrink-0 accent-primary" @change="updateSidebarDangerDialogOption" />
+ <span class="grid gap-0.5">
+ <span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.option.label }}</span>
+ <span class="text-xs leading-5 text-muted-foreground">{{ sidebarDangerDialogRequest.option.hint }}</span>
+ </span>
+ </label>
+ <label v-if="sidebarDangerDialogRequest.textInput" class="mb-3 grid gap-1.5 rounded-md border bg-muted/20 px-3 py-2 text-sm">
+ <span class="font-medium text-foreground">{{ sidebarDangerDialogRequest.textInput.label }}</span>
+ <Input :model-value="sidebarDangerDialogRequest.textInput.value" :inputmode="sidebarDangerDialogRequest.textInput.inputMode" :placeholder="sidebarDangerDialogRequest.textInput.placeholder" @update:model-value="updateSidebarDangerDialogTextInput" />
+ </label>
+ </template>
+ </SidebarDangerConfirmDialog>
+</template>
diff --git a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
index e4ce890fce..53db7181d9 100644
--- a/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
+++ b/apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue
@@ -11,6 +11,7 @@ import { useSidebarDatabaseSpecificMutationRuntime } from "@/composables/useSide
import { useSidebarTableMutationRuntime } from "@/composables/useSidebarTableMutationRuntime";
import { useSidebarTreeExportRuntime } from "@/composables/useSidebarTreeExportRuntime";
import { useSidebarTreeToolRuntime } from "@/composables/useSidebarTreeToolRuntime";
+import { canDropDatabaseNode, notifyDatabaseBrowserMutation } from "@/lib/database/databaseBrowserActions";
import { canDropDatabaseTables, canEmptyDatabaseTables, useDatabaseTableEmpty } from "@/composables/useDatabaseTableEmpty";
import { useI18n } from "vue-i18n";
import { translateBackendError } from "@/i18n/backend-errors";
@@ -124,7 +125,6 @@ import {
canEditDatabaseProperties as canEditDatabasePropertiesForNode,
connectionNamespaceCreationTarget,
editableDatabasePropertyGroups,
- supportsDatabaseCreation,
supportsDatabaseSearch,
supportsConnectionDatabaseBrowser,
supportsConnectionQueryActions,
@@ -3918,7 +3918,7 @@ const canSetCreateDatabaseLocale = computed(() => {
const canDropDatabase = computed(() => {
const config = activeNode.value.connectionId ? connectionStore.getConfig(activeNode.value.connectionId) : undefined;
- return activeNode.value.type === "database" && !isSqlServerLinkedNode(activeNode.value) && (supportsDatabaseCreation(config?.db_type) || supportsCreateDatabaseLocale(config?.db_type, config?.driver_profile));
+ return canDropDatabaseNode(activeNode.value, config);
});
const databasePropertyGroups = computed(() => {
@@ -4626,7 +4626,7 @@ async function confirmDropDatabase() {
}
const connectionId = node.connectionId;
- if (!connectionId || dropDatabaseLoading.value) return;
+ if (!connectionId || dropDatabaseLoading.value || !canDropDatabaseNode(node, connectionStore.getConfig(connectionId))) return false;
dropDatabaseLoading.value = true;
try {
await connectionStore.ensureConnected(connectionId);
@@ -4648,6 +4648,8 @@ async function confirmDropDatabase() {
connectionStore.removeTreeNode(node.id);
}
showDropDatabaseConfirm.value = false;
+ notifyDatabaseBrowserMutation({ connectionId, database: node.database || node.label, operation: "drop-database" });
+ queryStore.closeDatabaseTabs(connectionId, node.database || node.label);
} catch (e: any) {
toast(t("contextMenu.tableOperationFailed", { message: e?.message || String(e) }), 5000);
} finally {
diff --git a/apps/desktop/src/components/sidebar/__tests__/ConnectionTree.dangerDialogGuard.spec.ts b/apps/desktop/src/components/sidebar/__tests__/ConnectionTree.dangerDialogGuard.spec.ts
index 5149f1d89d..e6a5924b40 100644
--- a/apps/desktop/src/components/sidebar/__tests__/ConnectionTree.dangerDialogGuard.spec.ts
+++ b/apps/desktop/src/components/sidebar/__tests__/ConnectionTree.dangerDialogGuard.spec.ts
@@ -1,10 +1,10 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
-const connectionTreeSource = readFileSync(new URL("../ConnectionTree.vue", import.meta.url), "utf8");
+const dangerDialogHostSource = readFileSync(new URL("../SidebarDangerDialogHost.vue", import.meta.url), "utf8");
-describe("ConnectionTree danger dialog guard", () => {
+describe("Shared danger dialog guard", () => {
it("refuses to open a new danger dialog while a previous danger operation is still running", () => {
- expect(connectionTreeSource).toMatch(/function openSidebarDangerDialog\(request: SidebarDangerDialogRequest\) \{\s*if \(sidebarDangerRunningExecutionId\.value\) \{\s*toast\(t\("contextMenu\.dangerOperationAlreadyRunning"\), \d+\);\s*return;\s*\}/);
+ expect(dangerDialogHostSource).toMatch(/function showSidebarDangerDialog\(request: SidebarDangerDialogRequest\) \{\s*if \(sidebarDangerRunningExecutionId\.value[^\n]*\) \{\s*toast\(t\("contextMenu\.dangerOperationAlreadyRunning"\), \d+\);\s*return;\s*\}/);
});
});
diff --git a/apps/desktop/src/components/sidebar/__tests__/SidebarTreeRuntimeHost.elasticsearchClearGuard.spec.ts b/apps/desktop/src/components/sidebar/__tests__/SidebarTreeRuntimeHost.elasticsearchClearGuard.spec.ts
index 83dd3cce86..1b4ffec8a2 100644
--- a/apps/desktop/src/components/sidebar/__tests__/SidebarTreeRuntimeHost.elasticsearchClearGuard.spec.ts
+++ b/apps/desktop/src/components/sidebar/__tests__/SidebarTreeRuntimeHost.elasticsearchClearGuard.spec.ts
@@ -2,7 +2,7 @@ import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
const runtimeHostSource = readFileSync(new URL("../SidebarTreeRuntimeHost.vue", import.meta.url), "utf8");
-const connectionTreeSource = readFileSync(new URL("../ConnectionTree.vue", import.meta.url), "utf8");
+const dangerDialogHostSource = readFileSync(new URL("../SidebarDangerDialogHost.vue", import.meta.url), "utf8");
const dangerDialogSource = readFileSync(new URL("../../editor/DangerConfirmDialog.vue", import.meta.url), "utf8");
/**
@@ -50,7 +50,7 @@ describe("Elasticsearch clear-index wildcard guard wiring", () => {
});
it("forwards confirmDisabled from the sidebar request to the shared danger dialog", () => {
- expect(connectionTreeSource).toContain(':confirm-disabled="sidebarDangerDialogRequest.confirmDisabled"');
+ expect(dangerDialogHostSource).toContain(':confirm-disabled="sidebarDangerDialogRequest.confirmDisabled"');
});
it("honours confirmDisabled on both the button and the confirm handler", () => {
diff --git a/apps/desktop/src/composables/useDatabaseTableEmpty.ts b/apps/desktop/src/composables/useDatabaseTableEmpty.ts
index 1ef4f460e2..70a55de951 100644
--- a/apps/desktop/src/composables/useDatabaseTableEmpty.ts
+++ b/apps/desktop/src/composables/useDatabaseTableEmpty.ts
@@ -1,4 +1,5 @@
import { ref, shallowRef } from "vue";
+import { notifyDatabaseBrowserMutation } from "@/lib/database/databaseBrowserActions";
import { useI18n } from "vue-i18n";
import { useToast } from "@/composables/useToast";
import { useConnectionStore } from "@/stores/connectionStore";
@@ -180,6 +181,7 @@ export function useDatabaseTableEmpty(openDialog: (request: SidebarDangerDialogR
await connections.refreshObjectListTreeNode(connectionId, database, undefined, target.catalog).catch((error) => {
details.value += `\n${t("databaseEmpty.refreshFailed", { message: translateBackendError(t, error) })}`;
});
+ notifyDatabaseBrowserMutation({ connectionId, database, operation: operation === "empty" ? "empty" : "drop-tables" });
}
return complete;
} catch (error) {
diff --git a/apps/desktop/src/lib/database/databaseBrowserActions.ts b/apps/desktop/src/lib/database/databaseBrowserActions.ts
new file mode 100644
index 0000000000..9bb10a8ce4
--- /dev/null
+++ b/apps/desktop/src/lib/database/databaseBrowserActions.ts
@@ -0,0 +1,30 @@
+import { onBeforeUnmount } from "vue";
+import { supportsDatabaseCreation } from "@/lib/database/databaseCapabilities";
+import { supportsCreateDatabaseLocale } from "@/lib/database/createDatabaseSql";
+import { connectionIsEffectivelyReadOnly } from "@/lib/database/readOnlyWriteAccess";
+import { isSqlServerLinkedNode } from "@/lib/database/sqlServerLinkedServers";
+import type { ConnectionConfig, TreeNode } from "@/types/database";
+
+export function canDropDatabaseNode(node: TreeNode, connection?: ConnectionConfig): boolean {
+ return (
+ node.type === "database" && !!node.connectionId && !!node.database && !node.catalog && !isSqlServerLinkedNode(node) && !connectionIsEffectivelyReadOnly(connection) && (supportsDatabaseCreation(connection?.db_type) || supportsCreateDatabaseLocale(connection?.db_type, connection?.driver_profile))
+ );
+}
+
+export interface DatabaseBrowserMutation {
+ connectionId: string;
+ database: string;
+ operation: "empty" | "drop-tables" | "drop-database";
+}
+
+const mutationEvent = "dbx-database-browser-mutation";
+
+export function notifyDatabaseBrowserMutation(mutation: DatabaseBrowserMutation): void {
+ window.dispatchEvent(new CustomEvent(mutationEvent, { detail: mutation }));
+}
+
+export function useDatabaseBrowserMutation(handler: (mutation: DatabaseBrowserMutation) => void): void {
+ const listener = (event: Event) => handler((event as CustomEvent<DatabaseBrowserMutation>).detail);
+ window.addEventListener(mutationEvent, listener);
+ onBeforeUnmount(() => window.removeEventListener(mutationEvent, listener));
+}
diff --git a/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts b/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts
index 6ab82fc065..92a647e423 100644
--- a/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts
+++ b/apps/desktop/src/lib/sidebar/sidebarDangerDialog.ts
@@ -43,3 +43,17 @@ export interface SidebarDangerDialogRequest {
cancelRunning?: () => void | Promise<void>;
confirm: () => void | boolean | Promise<void | boolean>;
}
+
+// One application-level host keeps requests alive when their originating tab closes.
+let dialogHost: ((request: SidebarDangerDialogRequest) => void) | undefined;
+
+export function registerSidebarDangerDialogHost(host: (request: SidebarDangerDialogRequest) => void): () => void {
+ dialogHost = host;
+ return () => {
+ if (dialogHost === host) dialogHost = undefined;
+ };
+}
+
+export function openSidebarDangerDialog(request: SidebarDangerDialogRequest): void {
+ dialogHost?.(request);
+}
diff --git a/packages/app-tests/sidebarDialogRouting.test.ts b/packages/app-tests/sidebarDialogRouting.test.ts
index aa9862c647..7a9ddce595 100644
--- a/packages/app-tests/sidebarDialogRouting.test.ts
+++ b/packages/app-tests/sidebarDialogRouting.test.ts
@@ -2,6 +2,8 @@ import { strict as assert } from "node:assert";
import { readFileSync } from "node:fs";
import { test } from "vitest";
+const app = readFileSync("apps/desktop/src/App.vue", "utf8");
+const dangerHost = readFileSync("apps/desktop/src/components/sidebar/SidebarDangerDialogHost.vue", "utf8");
const connectionTree = readFileSync("apps/desktop/src/components/sidebar/ConnectionTree.vue", "utf8");
const treeItem = readFileSync("apps/desktop/src/components/sidebar/TreeItem.vue", "utf8");
const runtimeHost = readFileSync("apps/desktop/src/components/sidebar/SidebarTreeRuntimeHost.vue", "utf8");
@@ -15,19 +17,21 @@ function occurrences(source: string, value: string): number {
return source.split(value).length - 1;
}
-test("sidebar routes destructive confirmations through one tree-level host", () => {
+test("sidebar routes destructive confirmations through one application-level host", () => {
assert.match(runtimeHost, /emit\("open-danger-dialog", route\.createRequest\(\)\)/);
- assert.match(connectionTree, /function openSidebarDangerDialog\(request: SidebarDangerDialogRequest\)/);
- assert.equal(occurrences(connectionTree, "<SidebarDangerConfirmDialog"), 1);
+ assert.match(dangerHost, /function showSidebarDangerDialog\(request: SidebarDangerDialogRequest\)/);
+ assert.match(connectionTree, /@open-danger-dialog="openSidebarDangerDialog"/);
+ assert.equal(occurrences(app, "<SidebarDangerDialogHost"), 1);
+ assert.equal(occurrences(dangerHost, "<SidebarDangerConfirmDialog"), 1);
assert.doesNotMatch(treeItem, /<DangerConfirmDialog/);
});
-test("tree-level danger routing preserves cancel and close-on-confirm behavior", () => {
- assert.match(connectionTree, /v-model:open="sidebarDangerDialogOpen"/);
- assert.match(connectionTree, /if \(request\.closeOnConfirm !== false\) sidebarDangerDialogOpen\.value = false/);
- assert.match(connectionTree, /await request\.confirm\(\)/);
- assert.match(connectionTree, /sidebarDangerDialogOpen\.value = false/);
- assert.match(connectionTree, /sidebarDangerDialogConfirming\.value = false/);
+test("application-level danger routing preserves cancel and close-on-confirm behavior", () => {
+ assert.match(dangerHost, /v-model:open="sidebarDangerDialogOpen"/);
+ assert.match(dangerHost, /if \(request\.closeOnConfirm !== false\) sidebarDangerDialogOpen\.value = false/);
+ assert.match(dangerHost, /await request\.confirm\(\)/);
+ assert.match(dangerHost, /sidebarDangerDialogOpen\.value = false/);
+ assert.match(dangerHost, /sidebarDangerDialogConfirming\.value = false/);
});
test("remaining form dialogs render once at tree level and keep confirm/cancel bindings", () => {