feat(toolbar): add backup and MCP shortcuts

This commit is contained in:
t8y2 committed 2026-09-28 03:08:00 +08:00
1 parent b49e288dde
commit 0c61f045c1
14 files changed
+81 -60

No files matched your search

+2
View File
@@ -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')"
/>
<div :class="isDetachedWindowContext ? 'flex-1 flex min-h-0' : isClassicLayout ? 'app-layout-classic flex-1 flex min-h-0' : 'app-panel-gutter flex-1 flex min-h-0 gap-1 p-1'">
@@ -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);
@@ -50,7 +50,12 @@ vi.mock("@/components/ui/tooltip", () => ({
TooltipContent: { name: "TooltipContentStub", template: `<span><slot /></span>` },
}));
vi.mock("@/components/ui/LightDropdown.vue", () => ({
default: { name: "LightDropdownStub", template: `<div />` },
default: {
name: "LightDropdownStub",
props: ["items"],
emits: ["update:modelValue"],
template: `<div data-light-dropdown><button v-for="item in items" :key="item.value" :data-toolbar-menu-item="item.value" :disabled="item.disabled" @click="$emit('update:modelValue', item.value)">{{ item.label }}</button></div>`,
},
}));
vi.mock("@/components/layout/WindowControls.vue", () => ({
default: { name: "WindowControlsStub", template: `<div />` },
@@ -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<HTMLButtonElement>('[data-toolbar-menu-item="database-backups"]');
const mcpButton = host.querySelector<HTMLButtonElement>('[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();
});
});
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -7308,7 +7308,7 @@ export default withEnglishFallback({
upToDate: "最新です",
openDriverManager: "ドライバー管理を開く",
openPluginCenter: "プラグインセンターを開く",
openMcpSettings: "MCP 設定を開く",
openMcpSettings: "MCP 設定",
updateRestartHint: "コンポーネントの更新は、DBX の更新後に正常に再起動したあとで実行されます。アクティブな接続がある場合、ドライバーの更新は安全になるまで延期されます。",
debugLoggingEnabled: "デバッグログを有効にする",
debugLoggingEnabledDescription: "トラブルシューティング時に、より詳細なローカル診断ログを記録します。デフォルトでは無効です。",
+1 -1
View File
@@ -7053,7 +7053,7 @@ export default withEnglishFallback({
upToDate: "최신 버전",
openDriverManager: "드라이버 관리 열기",
openPluginCenter: "플러그인 센터 열기",
openMcpSettings: "MCP 설정 열기",
openMcpSettings: "MCP 설정",
updateRestartHint: "구성 요소 업데이트는 DBX 업데이트 후 다시 시작이 완료되면 실행됩니다. 활성 연결이 있으면 드라이버 업데이트가 안전한 시점까지 연기될 수 있습니다.",
updateDownloadSource: "업데이트 다운로드 소스",
updateDownloadSourceDescription: "앱 업데이트, 데이터베이스 에이전트, 드라이버, 관리 JRE를 다운로드할 위치를 선택하세요. 공식 소스를 권장합니다. 중국 본토 네트워크에서는 CNB가 더 빠를 수 있습니다.",
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -8505,7 +8505,7 @@ export default withEnglishFallback({
upToDate: "Актуально",
openDriverManager: "Открыть менеджер драйверов",
openPluginCenter: "Открыть центр плагинов",
openMcpSettings: "Открыть настройки MCP",
openMcpSettings: "Настройки MCP",
updateRestartHint: "Обновления компонентов выполняются после успешного перезапуска DBX при обновлении. Активные подключения могут отложить обновления драйверов до безопасного момента.",
updateDownloadSource: "Источник загрузки обновлений",
updateDownloadSourceDescription: "Выберите, откуда скачиваются обновления приложения, агенты баз данных, драйверы и управляемые JRE. Рекомендуется официальный источник; CNB может быть быстрее в сетях материкового Китая.",
+1 -1
View File
@@ -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.",
+1 -1
View File
@@ -7965,7 +7965,7 @@ export default withEnglishFallback({
upToDate: "已是最新",
openDriverManager: "打开驱动管理",
openPluginCenter: "打开插件中心",
openMcpSettings: "打开 MCP 设置",
openMcpSettings: "MCP 设置",
updateRestartHint: "组件更新会在 DBX 成功升级并重启后执行。活动连接占用驱动时,会暂缓驱动更新直到安全时机。",
updateDownloadSource: "更新下载源",
updateDownloadSourceDescription: "选择应用更新、数据库 Agent、驱动和托管 JRE 的下载来源。官方源为推荐选项,CNB 适合国内网络环境。",
+1 -1
View File
@@ -6601,7 +6601,7 @@ export default withEnglishFallback({
upToDate: "已是最新",
openDriverManager: "開啟驅動程式管理",
openPluginCenter: "開啟外掛中心",
openMcpSettings: "開啟 MCP 設定",
openMcpSettings: "MCP 設定",
updateRestartHint: "元件更新會在 DBX 成功更新並重新啟動後執行。作用中的連線佔用驅動程式時,會暫緩驅動程式更新直到安全時機。",
debugLoggingEnabled: "啟用偵錯日誌",
debugLoggingEnabledDescription: "開啟後在本機記錄更詳細的使用者側診斷日誌,回報問題時可暫時開啟;預設關閉。",