From 0c61f045c16e2d14d3043977c0aad173964cd647 Mon Sep 17 00:00:00 2001 From: t8y2 Date: Mon, 28 Sep 2026 03:08:00 +0800 Subject: [PATCH] feat(toolbar): add backup and MCP shortcuts --- apps/desktop/src/App.vue | 2 + .../src/components/layout/AppToolbar.vue | 84 ++++++++----------- .../__tests__/AlwaysOnTopButton.spec.ts | 33 +++++++- apps/desktop/src/i18n/locales/az.ts | 2 +- apps/desktop/src/i18n/locales/en.ts | 2 +- apps/desktop/src/i18n/locales/es.ts | 2 +- apps/desktop/src/i18n/locales/it.ts | 2 +- apps/desktop/src/i18n/locales/ja.ts | 2 +- apps/desktop/src/i18n/locales/ko.ts | 2 +- apps/desktop/src/i18n/locales/pt-BR.ts | 2 +- apps/desktop/src/i18n/locales/ru.ts | 2 +- apps/desktop/src/i18n/locales/tr.ts | 2 +- apps/desktop/src/i18n/locales/zh-CN.ts | 2 +- apps/desktop/src/i18n/locales/zh-TW.ts | 2 +- 14 files changed, 81 insertions(+), 60 deletions(-) diff --git a/apps/desktop/src/App.vue b/apps/desktop/src/App.vue index 6b993d6971..c44ead14e2 100644 --- a/apps/desktop/src/App.vue +++ b/apps/desktop/src/App.vue @@ -4210,6 +4210,8 @@ onUnmounted(() => { @open-sql-file="dialogs.showSqlFileDialog.value = true" @open-schema-diff="dialogs.showSchemaDiffDialog.value = true" @open-data-compare="dialogs.showDataCompareDialog.value = true" + @open-backups="openSettings('backups')" + @open-mcp-settings="openSettings('mcp')" />
diff --git a/apps/desktop/src/components/layout/AppToolbar.vue b/apps/desktop/src/components/layout/AppToolbar.vue index 4ae0833e4c..6cd444b02a 100644 --- a/apps/desktop/src/components/layout/AppToolbar.vue +++ b/apps/desktop/src/components/layout/AppToolbar.vue @@ -2,10 +2,10 @@ import { computed, ref, onMounted, onBeforeUnmount, h, nextTick, watch } from "vue"; import { useI18n } from "vue-i18n"; import { invoke } from "@tauri-apps/api/core"; -import { ChevronsRight, DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, CloudDownload, Package, PlugZap, FileDown, FolderTree, Pin, PinOff } from "@lucide/vue"; +import { ChevronsRight, DatabaseZap, FilePlus2, Moon, Sun, SunMoon, History, Bot, ArrowLeftRight, FileCode, BookMarked, GitCompareArrows, TableProperties, Settings, CloudDownload, Package, PlugZap, FileDown, FolderTree, Pin, PinOff, CalendarClock, Waypoints } from "@lucide/vue"; import { Button } from "@/components/ui/button"; import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip"; -import LightDropdown from "@/components/ui/LightDropdown.vue"; +import LightDropdown, { type LightDropdownItem } from "@/components/ui/LightDropdown.vue"; import WindowControls from "@/components/layout/WindowControls.vue"; import ExportProgressPopover from "@/components/export/ExportProgressPopover.vue"; import ToolbarUpdateIcon from "@/components/layout/ToolbarUpdateIcon.vue"; @@ -73,6 +73,8 @@ const emit = defineEmits<{ "open-sql-file": []; "open-schema-diff": []; "open-data-compare": []; + "open-backups": []; + "open-mcp-settings": []; }>(); const { t } = useI18n(); @@ -429,11 +431,12 @@ onBeforeUnmount(() => { // ──────────── Left-side "More" items ──────────── -const moreItems = computed(() => { - const items: Array<{ value: string; label: string; icon: any; action: () => void; disabled: boolean }> = []; +type ToolbarMenuItem = LightDropdownItem & { action: () => void }; - // Hidden left-side items go into "More" - if (!toolbarItems.value.dataTransfer) { +function buildToolbarMenuItems(includeVisiblePrimaryItems: boolean): ToolbarMenuItem[] { + const items: ToolbarMenuItem[] = []; + + if (includeVisiblePrimaryItems || !toolbarItems.value.dataTransfer) { items.push({ value: "transfer", label: t("transfer.dataTransfer"), @@ -442,20 +445,18 @@ const moreItems = computed(() => { disabled: !props.hasConnections, }); } - if (!toolbarItems.value.driverManager) { + if (includeVisiblePrimaryItems || !toolbarItems.value.driverManager) { items.push({ value: "driver-store", - label: t("toolbar.driverManager"), + label: props.agentDriverUpdateCount > 0 ? `${t("toolbar.driverManager")} (${props.agentDriverUpdateCount})` : t("toolbar.driverManager"), icon: Package, action: () => emit("open-driver-store"), disabled: false, }); } - if (!toolbarItems.value.pluginCenter) { + if (includeVisiblePrimaryItems || !toolbarItems.value.pluginCenter) { items.push({ value: "plugin-center", label: t("toolbar.pluginCenter"), icon: PlugZap, action: () => emit("open-plugin-center"), disabled: false }); } - - // "More" menu items (individually toggleable) if (toolbarItems.value.sqlFile) { items.push({ value: "sql-file", @@ -483,52 +484,39 @@ const moreItems = computed(() => { disabled: !props.hasConnections, }); } + items.push({ + value: "database-backups", + label: t("databaseBackup.title"), + icon: CalendarClock, + action: () => emit("open-backups"), + disabled: false, + }); + items.push({ + value: "mcp-settings", + label: t("settings.openMcpSettings"), + icon: Waypoints, + action: () => emit("open-mcp-settings"), + disabled: false, + }); - // Append overflowed right-side items at the end - for (const ri of overflowRightMenuItems.value) { + for (const item of overflowRightMenuItems.value) { items.push({ - value: `right-${ri.value}`, - label: ri.label, - icon: ri.icon, - action: ri.action, - disabled: ri.disabled, + value: `right-${item.value}`, + label: item.label, + icon: item.icon, + action: item.action, + disabled: item.disabled, }); } return items; -}); +} + +const moreItems = computed(() => buildToolbarMenuItems(false)); const showMoreDropdown = computed(() => moreItems.value.length > 0); -const collapsedItems = computed(() => { - const items: Array<{ value: string; label: string; icon: any; action: () => void; disabled: boolean }> = []; - if (toolbarItems.value.dataTransfer) { - items.push({ - value: "transfer", - label: t("transfer.dataTransfer"), - icon: ArrowLeftRight, - action: () => emit("open-transfer"), - disabled: !props.hasConnections, - }); - } - if (toolbarItems.value.driverManager) { - items.push({ - value: "driver-store", - label: props.agentDriverUpdateCount > 0 ? `${t("toolbar.driverManager")} (${props.agentDriverUpdateCount})` : t("toolbar.driverManager"), - icon: Package, - action: () => emit("open-driver-store"), - disabled: false, - }); - } - if (toolbarItems.value.pluginCenter) { - items.push({ value: "plugin-center", label: t("toolbar.pluginCenter"), icon: PlugZap, action: () => emit("open-plugin-center"), disabled: false }); - } - // Always include moreItems (may contain hidden left-side items + overflowed right items) - if (moreItems.value.length > 0) { - items.push(...moreItems.value); - } - return items; -}); +const collapsedItems = computed(() => buildToolbarMenuItems(true)); function runMoreItem(value: string) { const item = moreItems.value.find((i) => i.value === value); diff --git a/apps/desktop/src/components/layout/__tests__/AlwaysOnTopButton.spec.ts b/apps/desktop/src/components/layout/__tests__/AlwaysOnTopButton.spec.ts index 6c580bae2b..20d8f0c77c 100644 --- a/apps/desktop/src/components/layout/__tests__/AlwaysOnTopButton.spec.ts +++ b/apps/desktop/src/components/layout/__tests__/AlwaysOnTopButton.spec.ts @@ -50,7 +50,12 @@ vi.mock("@/components/ui/tooltip", () => ({ TooltipContent: { name: "TooltipContentStub", template: `` }, })); vi.mock("@/components/ui/LightDropdown.vue", () => ({ - default: { name: "LightDropdownStub", template: `
` }, + default: { + name: "LightDropdownStub", + props: ["items"], + emits: ["update:modelValue"], + template: `
`, + }, })); vi.mock("@/components/layout/WindowControls.vue", () => ({ default: { name: "WindowControlsStub", template: `
` }, @@ -215,4 +220,30 @@ describe("always-on-top button visibility", () => { unmount(); }); + + it("exposes backup and MCP shortcuts from the more menu", async () => { + const openBackups = vi.fn(); + const openMcpSettings = vi.fn(); + const { host, unmount } = mount(AppToolbar, { + ...toolbarProps, + onOpenBackups: openBackups, + onOpenMcpSettings: openMcpSettings, + }); + await settled(); + await nextTick(); + + const backupButton = host.querySelector('[data-toolbar-menu-item="database-backups"]'); + const mcpButton = host.querySelector('[data-toolbar-menu-item="mcp-settings"]'); + + expect(backupButton).not.toBeNull(); + expect(mcpButton).not.toBeNull(); + + backupButton?.click(); + mcpButton?.click(); + + expect(openBackups).toHaveBeenCalledOnce(); + expect(openMcpSettings).toHaveBeenCalledOnce(); + + unmount(); + }); }); diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.ts index 12a9183cb4..35e055e8c5 100644 --- a/apps/desktop/src/i18n/locales/az.ts +++ b/apps/desktop/src/i18n/locales/az.ts @@ -7327,7 +7327,7 @@ export default withEnglishFallback({ upToDate: "Ən son versiyadadır", openDriverManager: "Sürücü idarəetməsini aç", openPluginCenter: "Plagin mərkəzini aç", - openMcpSettings: "MCP parametrlərini aç", + openMcpSettings: "MCP parametrləri", updateRestartHint: "Komponent yeniləmələri DBX uğurla yenilənib yenidən başladıqdan sonra icra olunur. Aktiv əlaqələr sürücü yeniləmələrini təhlükəsiz vaxta qədər təxirə sala bilər.", updateDownloadSource: "Yeniləmələrin endirmə mənbəyi", updateDownloadSourceDescription: "Tətbiq yeniləmələrinin, verilənlər bazası agentlərinin, drayverlərin və idarə olunan JRE-lərin haradan endiriləcəyini seçin. Rəsmi mənbə tövsiyə olunur; CNB materik Çin şəbəkələrində daha sürətli ola bilər.", diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.ts index b59c01aabf..8486437d5c 100644 --- a/apps/desktop/src/i18n/locales/en.ts +++ b/apps/desktop/src/i18n/locales/en.ts @@ -7999,7 +7999,7 @@ export default { upToDate: "Up to date", openDriverManager: "Open Driver Manager", openPluginCenter: "Open Plugin Center", - openMcpSettings: "Open MCP settings", + openMcpSettings: "MCP Settings", updateRestartHint: "Component updates run after a successful DBX upgrade restart. Active connections can postpone driver updates until it is safe.", updateDownloadSource: "Update download source", updateDownloadSourceDescription: "Choose where app updates, database agents, drivers, and managed JREs are downloaded from. The official source is recommended; CNB can be faster on mainland China networks.", diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.ts index 4156913a17..420cdcb717 100644 --- a/apps/desktop/src/i18n/locales/es.ts +++ b/apps/desktop/src/i18n/locales/es.ts @@ -7353,7 +7353,7 @@ export default withEnglishFallback({ upToDate: "Actualizado", openDriverManager: "Abrir el administrador de controladores", openPluginCenter: "Abrir el centro de plugins", - openMcpSettings: "Abrir la configuración de MCP", + openMcpSettings: "Configuración de MCP", updateRestartHint: "Las actualizaciones de componentes se ejecutan después de reiniciar DBX tras una actualización correcta. Las conexiones activas pueden posponer las actualizaciones de controladores hasta que sea seguro.", updateDownloadSource: "Origen de descarga de actualizaciones", updateDownloadSourceDescription: "Elige de dónde se descargan los instaladores de actualización. Se recomienda la fuente oficial; CNB puede ser más rápido en redes de China continental.", diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.ts index 289b0ad9ab..6fd6da526d 100644 --- a/apps/desktop/src/i18n/locales/it.ts +++ b/apps/desktop/src/i18n/locales/it.ts @@ -7278,7 +7278,7 @@ export default withEnglishFallback({ upToDate: "Aggiornato", openDriverManager: "Apri gestione driver", openPluginCenter: "Apri centro plugin", - openMcpSettings: "Apri impostazioni MCP", + openMcpSettings: "Impostazioni MCP", updateRestartHint: "Gli aggiornamenti dei componenti vengono eseguiti dopo il riavvio di DBX al termine di un aggiornamento riuscito. Le connessioni attive possono posticipare gli aggiornamenti dei driver fino a quando è sicuro.", updateDownloadSource: "Fonte download aggiornamenti", updateDownloadSourceDescription: "Scegli da dove scaricare gli installer degli aggiornamenti. La fonte ufficiale è consigliata; CNB può essere più veloce sulle reti della Cina continentale.", diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.ts index cce07f5d09..15dc558d2f 100644 --- a/apps/desktop/src/i18n/locales/ja.ts +++ b/apps/desktop/src/i18n/locales/ja.ts @@ -7308,7 +7308,7 @@ export default withEnglishFallback({ upToDate: "最新です", openDriverManager: "ドライバー管理を開く", openPluginCenter: "プラグインセンターを開く", - openMcpSettings: "MCP 設定を開く", + openMcpSettings: "MCP 設定", updateRestartHint: "コンポーネントの更新は、DBX の更新後に正常に再起動したあとで実行されます。アクティブな接続がある場合、ドライバーの更新は安全になるまで延期されます。", debugLoggingEnabled: "デバッグログを有効にする", debugLoggingEnabledDescription: "トラブルシューティング時に、より詳細なローカル診断ログを記録します。デフォルトでは無効です。", diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.ts index 2cd6c25d05..4f93ac2d5c 100644 --- a/apps/desktop/src/i18n/locales/ko.ts +++ b/apps/desktop/src/i18n/locales/ko.ts @@ -7053,7 +7053,7 @@ export default withEnglishFallback({ upToDate: "최신 버전", openDriverManager: "드라이버 관리 열기", openPluginCenter: "플러그인 센터 열기", - openMcpSettings: "MCP 설정 열기", + openMcpSettings: "MCP 설정", updateRestartHint: "구성 요소 업데이트는 DBX 업데이트 후 다시 시작이 완료되면 실행됩니다. 활성 연결이 있으면 드라이버 업데이트가 안전한 시점까지 연기될 수 있습니다.", updateDownloadSource: "업데이트 다운로드 소스", updateDownloadSourceDescription: "앱 업데이트, 데이터베이스 에이전트, 드라이버, 관리 JRE를 다운로드할 위치를 선택하세요. 공식 소스를 권장합니다. 중국 본토 네트워크에서는 CNB가 더 빠를 수 있습니다.", diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.ts index 37bd716cea..c99b58880a 100644 --- a/apps/desktop/src/i18n/locales/pt-BR.ts +++ b/apps/desktop/src/i18n/locales/pt-BR.ts @@ -7279,7 +7279,7 @@ export default withEnglishFallback({ upToDate: "Atualizado", openDriverManager: "Abrir gerenciador de drivers", openPluginCenter: "Abrir central de plugins", - openMcpSettings: "Abrir configurações do MCP", + openMcpSettings: "Configurações do MCP", updateRestartHint: "As atualizações dos componentes são executadas após o DBX reiniciar com sucesso após uma atualização. Conexões ativas podem adiar as atualizações de drivers até que seja seguro.", updateDownloadSource: "Fonte de download de atualização", updateDownloadSourceDescription: "Escolha de onde os instaladores de atualização no aplicativo são baixados. A fonte oficial é recomendada; CNB pode ser mais rápido em redes da China continental.", diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.ts index 4935bd5878..f48b9dd62f 100644 --- a/apps/desktop/src/i18n/locales/ru.ts +++ b/apps/desktop/src/i18n/locales/ru.ts @@ -8505,7 +8505,7 @@ export default withEnglishFallback({ upToDate: "Актуально", openDriverManager: "Открыть менеджер драйверов", openPluginCenter: "Открыть центр плагинов", - openMcpSettings: "Открыть настройки MCP", + openMcpSettings: "Настройки MCP", updateRestartHint: "Обновления компонентов выполняются после успешного перезапуска DBX при обновлении. Активные подключения могут отложить обновления драйверов до безопасного момента.", updateDownloadSource: "Источник загрузки обновлений", updateDownloadSourceDescription: "Выберите, откуда скачиваются обновления приложения, агенты баз данных, драйверы и управляемые JRE. Рекомендуется официальный источник; CNB может быть быстрее в сетях материкового Китая.", diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.ts index ce57c7b192..fe005e3426 100644 --- a/apps/desktop/src/i18n/locales/tr.ts +++ b/apps/desktop/src/i18n/locales/tr.ts @@ -7209,7 +7209,7 @@ export default withEnglishFallback({ upToDate: "Güncel", openDriverManager: "Sürücü Yöneticisi'ni aç", openPluginCenter: "Eklenti merkezini aç", - openMcpSettings: "MCP ayarlarını aç", + openMcpSettings: "MCP ayarları", updateRestartHint: "Bileşen güncellemeleri, DBX başarıyla güncellenip yeniden başlatıldıktan sonra çalıştırılır. Etkin bağlantılar sürücü güncellemelerini güvenli olana kadar erteleyebilir.", updateDownloadSource: "Güncelleme indirme kaynağı", updateDownloadSourceDescription: "Uygulama güncellemelerinin, veritabanı agent'larının, sürücülerin ve yönetilen JRE'lerin nereden indirileceğini seçin. Resmî kaynak önerilir; Çin anakarası ağlarında CNB daha hızlı olabilir.", diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.ts index 3cb961b620..8f1f63feda 100644 --- a/apps/desktop/src/i18n/locales/zh-CN.ts +++ b/apps/desktop/src/i18n/locales/zh-CN.ts @@ -7965,7 +7965,7 @@ export default withEnglishFallback({ upToDate: "已是最新", openDriverManager: "打开驱动管理", openPluginCenter: "打开插件中心", - openMcpSettings: "打开 MCP 设置", + openMcpSettings: "MCP 设置", updateRestartHint: "组件更新会在 DBX 成功升级并重启后执行。活动连接占用驱动时,会暂缓驱动更新直到安全时机。", updateDownloadSource: "更新下载源", updateDownloadSourceDescription: "选择应用更新、数据库 Agent、驱动和托管 JRE 的下载来源。官方源为推荐选项,CNB 适合国内网络环境。", diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.ts index b2b4777c5a..8d3f20c90f 100644 --- a/apps/desktop/src/i18n/locales/zh-TW.ts +++ b/apps/desktop/src/i18n/locales/zh-TW.ts @@ -6601,7 +6601,7 @@ export default withEnglishFallback({ upToDate: "已是最新", openDriverManager: "開啟驅動程式管理", openPluginCenter: "開啟外掛中心", - openMcpSettings: "開啟 MCP 設定", + openMcpSettings: "MCP 設定", updateRestartHint: "元件更新會在 DBX 成功更新並重新啟動後執行。作用中的連線佔用驅動程式時,會暫緩驅動程式更新直到安全時機。", debugLoggingEnabled: "啟用偵錯日誌", debugLoggingEnabledDescription: "開啟後在本機記錄更詳細的使用者側診斷日誌,回報問題時可暫時開啟;預設關閉。",