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。
TypeScript aicliclickhousedatabasedatabase-clientdatabase-managementdockerguimcpmongodbmysqlpostgresqlredisrustsql-serversqlitetaurivue
fix(import): name the dialog after the entry that opened it (#13047)
弈秋255af920bacd
diff --git a/apps/desktop/src/components/import/TableImportDialog.vue b/apps/desktop/src/components/import/TableImportDialog.vueindex 0ffbdc410d..ee25ed0f24 100644--- a/apps/desktop/src/components/import/TableImportDialog.vue+++ b/apps/desktop/src/components/import/TableImportDialog.vue@@ -250,6 +250,13 @@ const requiredUnmappedColumns = computed(() =>),);const isBatchImport = computed(() => targetMode.value === "create" && batchTasks.value.length > 1);+/**+ * The dialog is reachable from two entries: a table's own import (which lands on+ * that table, `prefillTable` set) and the database-level "Import data" entry,+ * which imports a backup and may create several tables. Both said+ * "Import table data", which reads wrong for the second one (#13029).+ */+const dialogTitle = computed(() => (props.prefillTable ? t("tableImport.title") : t("tableImport.titleDatabase")));const selectedBatchTasks = computed(() => batchTasks.value.filter((task) => task.selected));const batchTargetNamesValid = computed(() => {const tableNames = selectedBatchTasks.value.map((task) => task.tableName.trim().toLowerCase());@@ -1399,7 +1406,7 @@ watch(rawProgressPercent, (percent) => {<DialogHeader class="shrink-0 flex-row items-center pr-8" @pointerdown="startDialogDrag"><DialogTitle class="flex min-w-0 flex-1 items-center gap-2 text-base"><FileUp class="h-4 w-4" />- {{ t("tableImport.title") }}+ {{ dialogTitle }}</DialogTitle><Button variant="ghost" size="icon-sm" :aria-label="t('tableImport.minimize')" :title="t('tableImport.minimize')" @pointerdown.stop @click="minimizeImport"><Minimize2 class="h-4 w-4" />diff --git a/apps/desktop/src/components/import/__tests__/TableImportDialog.title.spec.ts b/apps/desktop/src/components/import/__tests__/TableImportDialog.title.spec.tsnew file mode 100644index 0000000000..4d8c53409f--- /dev/null+++ b/apps/desktop/src/components/import/__tests__/TableImportDialog.title.spec.ts@@ -0,0 +1,192 @@+// @vitest-environment happy-dom++import { createApp, defineComponent, h, nextTick, type App } from "vue";+import { afterEach, describe, expect, it, vi } from "vitest";+import i18n from "@/i18n";+import type { TableImportPreview } from "@/lib/backend/api";++const mocks = vi.hoisted(() => ({+ ensureConnected: vi.fn().mockResolvedValue(undefined),+ listTables: vi.fn().mockResolvedValue([{ name: "existing_target", table_type: "TABLE" }]),+ getColumns: vi.fn().mockResolvedValue([{ name: "id", data_type: "INTEGER", nullable: false }]),+ listDataTypes: vi.fn().mockResolvedValue(["INTEGER"]),+ previewTableImportFile: vi.fn(),+ importTableFile: vi.fn(),+ releaseTableImportSource: vi.fn().mockResolvedValue(undefined),+}));++vi.mock("@/stores/connectionStore", () => ({+ useConnectionStore: () => ({+ getConfig: (id: string) => (id === "connection-1" ? { id, name: "SQLite", db_type: "sqlite" } : undefined),+ ensureConnected: mocks.ensureConnected,+ invalidateMetadataCache: vi.fn(),+ refreshObjectListTreeNode: vi.fn().mockResolvedValue(undefined),+ }),+}));++vi.mock("@/stores/settingsStore", () => ({+ useSettingsStore: () => ({ editorSettings: {} }),+}));++vi.mock("@/lib/backend/api", () => ({+ listTables: mocks.listTables,+ getColumns: mocks.getColumns,+ listDataTypes: mocks.listDataTypes,+ previewTableImportFile: mocks.previewTableImportFile,+ releaseTableImportSource: mocks.releaseTableImportSource,+ importTableFile: mocks.importTableFile,+ cancelTableImport: vi.fn(),+}));++vi.mock("@/lib/backend/tauriRuntime", () => ({ isTauriRuntime: () => false }));+vi.mock("@/composables/useToast", () => ({ useToast: () => ({ toast: vi.fn() }) }));++vi.mock("@/components/ui/dialog", async () => {+ const { defineComponent, h } = await import("vue");+ const passthrough = defineComponent({+ setup(_props, { attrs, slots }) {+ return () => h("div", attrs, slots.default?.());+ },+ });+ return {+ Dialog: passthrough,+ DialogHeader: passthrough,+ DialogTitle: passthrough,+ DialogFooter: passthrough,+ DialogScrollContent: passthrough,+ };+});++vi.mock("@/components/ui/button", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Button: defineComponent({+ props: { disabled: Boolean },+ emits: ["click"],+ setup(props, { attrs, slots, emit }) {+ return () => h("button", { ...attrs, disabled: props.disabled, onClick: () => emit("click") }, slots.default?.());+ },+ }),+ };+});++vi.mock("@/components/ui/input", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Input: defineComponent({+ props: { modelValue: [String, Number], disabled: Boolean },+ emits: ["update:modelValue"],+ setup(props, { attrs, emit }) {+ return () => h("input", { ...attrs, value: props.modelValue, disabled: props.disabled, onInput: (event: Event) => emit("update:modelValue", (event.target as HTMLInputElement).value) });+ },+ }),+ };+});++vi.mock("@/components/ui/label", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ Label: defineComponent({+ setup(_props, { slots }) {+ return () => h("label", slots.default?.());+ },+ }),+ };+});++vi.mock("@/components/ui/select", async () => {+ const { defineComponent, h, inject, provide } = await import("vue");+ const passthrough = defineComponent({+ setup(_props, { slots }) {+ return () => h("div", slots.default?.());+ },+ });+ return {+ Select: defineComponent({+ props: { modelValue: String },+ emits: ["update:modelValue"],+ setup(_props, { emit, slots }) {+ provide("selectOption", (value: string) => emit("update:modelValue", value));+ return () => h("div", slots.default?.());+ },+ }),+ SelectContent: passthrough,+ SelectItem: defineComponent({+ props: { value: String },+ setup(props, { slots }) {+ const selectOption = inject<(value: string) => void>("selectOption");+ return () => h("span", { "data-select-option": props.value, onClick: () => selectOption?.(props.value || "") }, slots.default?.());+ },+ }),+ SelectTrigger: passthrough,+ SelectValue: passthrough,+ };+});++vi.mock("@/components/ui/searchable-select", async () => {+ const { defineComponent, h } = await import("vue");+ return {+ SearchableSelect: defineComponent({+ props: { modelValue: { type: String, default: "" }, options: { type: Array<string>, default: () => [] }, disabled: Boolean },+ emits: ["update:modelValue"],+ setup(props, { emit }) {+ return () =>+ h("select", { class: "existing-table-select-stub", value: props.modelValue, disabled: props.disabled, onChange: (event: Event) => emit("update:modelValue", (event.target as HTMLSelectElement).value) }, [+ h("option", { value: "" }),+ ...(props.options as string[]).map((option) => h("option", { value: option }, option)),+ ]);+ },+ }),+ };+});++import TableImportDialog from "@/components/import/TableImportDialog.vue";++const mountedApps: App[] = [];++const preview: TableImportPreview = {+ fileName: "rows.csv",+ filePath: "/tmp/rows.csv",+ sourceRef: "delimited-source",+ fileType: "csv",+ sizeBytes: 10,+ columns: ["id", "name"],+ rows: [[1, "a"]],+ totalRows: 1,+ totalRowsExact: true,+ sourceFingerprint: "rows-csv",+};++async function mountDialog(options: { prefillTable?: string } = {}) {+ mocks.previewTableImportFile.mockResolvedValue(preview);+ const container = document.createElement("div");+ document.body.append(container);+ const app = createApp(defineComponent({ setup: () => () => h(TableImportDialog, { open: true, prefillConnectionId: "connection-1", prefillDatabase: "main", ...(options.prefillTable ? { prefillTable: options.prefillTable } : {}) }) }));+ mountedApps.push(app);+ app.use(i18n);+ app.mount(container);+ await nextTick();+ await nextTick();+ return { header: document.body.querySelector("[data-dialog-title]")?.textContent?.trim() ?? document.body.textContent ?? "" };+}++afterEach(() => {+ for (const app of mountedApps.splice(0)) app.unmount();+ document.body.replaceChildren();+ vi.clearAllMocks();+});++describe("TableImportDialog title", () => {+ it("names the table when it is opened for one table", async () => {+ const { header } = await mountDialog({ prefillTable: "existing_target" });++ expect(header).toContain("Import Table Data");+ });++ it("drops the table wording when it is opened from the database-level entry (#13029)", async () => {+ const { header } = await mountDialog();++ expect(header).toContain("Import Data");+ expect(header).not.toContain("Import Table Data");+ });+});diff --git a/apps/desktop/src/i18n/locales/az.ts b/apps/desktop/src/i18n/locales/az.tsindex 58f7efc270..c2795159fc 100644--- a/apps/desktop/src/i18n/locales/az.ts+++ b/apps/desktop/src/i18n/locales/az.ts@@ -6463,6 +6463,7 @@ export default withEnglishFallback({},tableImport: {title: "Cədvəl məlumatlarını idxal et",+ titleDatabase: "Məlumatları idxal et",target: "Hədəf cədvəl",selectFile: "Fayl seç",changeFile: "Faylı dəyiş",diff --git a/apps/desktop/src/i18n/locales/en.ts b/apps/desktop/src/i18n/locales/en.tsindex 4dbb3526c5..a945987ad5 100644--- a/apps/desktop/src/i18n/locales/en.ts+++ b/apps/desktop/src/i18n/locales/en.ts@@ -7969,6 +7969,7 @@ export default {},tableImport: {title: "Import Table Data",+ titleDatabase: "Import Data",minimize: "Minimize import",restoreImport: "Restore import",backgroundWarning: "Rows may appear as they are written. Concurrent access to the target table may wait or fail because of database locks, transaction isolation, or constraints.",diff --git a/apps/desktop/src/i18n/locales/es.ts b/apps/desktop/src/i18n/locales/es.tsindex 1c4217bcfb..6ce3e2d27c 100644--- a/apps/desktop/src/i18n/locales/es.ts+++ b/apps/desktop/src/i18n/locales/es.ts@@ -7088,6 +7088,7 @@ export default withEnglishFallback({},tableImport: {title: "Importar datos a tabla",+ titleDatabase: "Importar datos",minimize: "Minimizar importación",restoreImport: "Restaurar importación",backgroundWarning: "Las filas pueden aparecer a medida que se escriben. El acceso simultáneo a la tabla de destino puede esperar o fallar debido a bloqueos de la base de datos, el aislamiento de transacciones o las restricciones.",diff --git a/apps/desktop/src/i18n/locales/id.ts b/apps/desktop/src/i18n/locales/id.tsindex 454270772b..5461b52a2e 100644--- a/apps/desktop/src/i18n/locales/id.ts+++ b/apps/desktop/src/i18n/locales/id.ts@@ -7128,6 +7128,7 @@ export default withEnglishFallback({tableImport: {title: "Impor Data Tabel",+ titleDatabase: "Impor Data",minimize: "Perkecil impor",restoreImport: "Pulihkan tampilan impor",backgroundWarning: "Baris mungkin muncul saat sedang ditulis. Akses bersamaan ke tabel target dapat menunggu atau gagal karena penguncian database, isolasi transaksi, atau batasan (constraint).",diff --git a/apps/desktop/src/i18n/locales/it.ts b/apps/desktop/src/i18n/locales/it.tsindex eaae2223d8..9f0986c93e 100644--- a/apps/desktop/src/i18n/locales/it.ts+++ b/apps/desktop/src/i18n/locales/it.ts@@ -6902,6 +6902,7 @@ export default withEnglishFallback({},tableImport: {title: "Importa Dati Tabella",+ titleDatabase: "Importa Dati",minimize: "Riduci a icona l'importazione",restoreImport: "Ripristina importazione",backgroundWarning: "Le righe possono comparire man mano che vengono scritte. L'accesso simultaneo alla tabella di destinazione può attendere o non riuscire a causa di blocchi del database, dell'isolamento delle transazioni o dei vincoli.",diff --git a/apps/desktop/src/i18n/locales/ja.ts b/apps/desktop/src/i18n/locales/ja.tsindex 238856c704..7f5050cdee 100644--- a/apps/desktop/src/i18n/locales/ja.ts+++ b/apps/desktop/src/i18n/locales/ja.ts@@ -6921,6 +6921,7 @@ export default withEnglishFallback({},tableImport: {title: "テーブルデータをインポート",+ titleDatabase: "データをインポート",minimize: "インポートを最小化",restoreImport: "インポートを復元",backgroundWarning: "書き込み中の行は順次表示される場合があります。対象テーブルへの同時アクセスは、データベースロック、トランザクション分離、制約により待機または失敗することがあります。",diff --git a/apps/desktop/src/i18n/locales/ko.ts b/apps/desktop/src/i18n/locales/ko.tsindex acccee8ee9..77b2e53f97 100644--- a/apps/desktop/src/i18n/locales/ko.ts+++ b/apps/desktop/src/i18n/locales/ko.ts@@ -6789,6 +6789,7 @@ export default withEnglishFallback({},tableImport: {title: "테이블 데이터 가져오기",+ titleDatabase: "데이터 가져오기",minimize: "가져오기 창 최소화",restoreImport: "가져오기 창 복원",backgroundWarning: "데이터를 쓰는 동안 행이 순차적으로 표시될 수 있습니다. 대상 테이블에 동시에 접근하면 데이터베이스 잠금, 트랜잭션 격리 또는 제약 조건으로 인해 대기하거나 실패할 수 있습니다.",diff --git a/apps/desktop/src/i18n/locales/pl.ts b/apps/desktop/src/i18n/locales/pl.tsindex f1b73d6b1d..1a3a1eddb2 100644--- a/apps/desktop/src/i18n/locales/pl.ts+++ b/apps/desktop/src/i18n/locales/pl.ts@@ -7183,6 +7183,7 @@ export default withEnglishFallback({},tableImport: {title: "Aktualizacja zabezpieczeń danych",+ titleDatabase: "Importuj dane",minimize: "Minimalizuj import",restoreImport: "Przywróć import",backgroundWarning: "Wiersze mogą pojawiać się w miarę ich zapisywania. Równoczesny dostęp do tabeli docelowej może oczekiwać lub zakończyć się błędem z powodu blokad bazy danych, izolacji transakcji lub ograniczeń.",diff --git a/apps/desktop/src/i18n/locales/pt-BR.ts b/apps/desktop/src/i18n/locales/pt-BR.tsindex 4865424801..3c64ca876d 100644--- a/apps/desktop/src/i18n/locales/pt-BR.ts+++ b/apps/desktop/src/i18n/locales/pt-BR.ts@@ -6901,6 +6901,7 @@ export default withEnglishFallback({},tableImport: {title: "Importar Dados da Tabela",+ titleDatabase: "Importar Dados",minimize: "Minimizar importação",restoreImport: "Restaurar importação",backgroundWarning: "As linhas podem aparecer conforme são gravadas. O acesso simultâneo à tabela de destino pode aguardar ou falhar devido a bloqueios do banco de dados, ao isolamento de transações ou a restrições.",diff --git a/apps/desktop/src/i18n/locales/ru.ts b/apps/desktop/src/i18n/locales/ru.tsindex 8c77927eff..27c49a7877 100644--- a/apps/desktop/src/i18n/locales/ru.ts+++ b/apps/desktop/src/i18n/locales/ru.ts@@ -8224,6 +8224,7 @@ export default withEnglishFallback({},tableImport: {title: "Импорт данных таблицы",+ titleDatabase: "Импорт данных",minimize: "Свернуть окно импорта",restoreImport: "Восстановить окно импорта",backgroundWarning: "Строки могут появляться по мере записи. Параллельный доступ к целевой таблице может ожидать или завершиться ошибкой из-за блокировок базы данных, изоляции транзакций или ограничений.",diff --git a/apps/desktop/src/i18n/locales/th.ts b/apps/desktop/src/i18n/locales/th.tsindex 1ab6e68e05..7c6fadfa19 100644--- a/apps/desktop/src/i18n/locales/th.ts+++ b/apps/desktop/src/i18n/locales/th.ts@@ -8612,6 +8612,7 @@ export default withEnglishFallback({},tableImport: {title: "นำเข้าข้อมูล Table",+ titleDatabase: "นำเข้าข้อมูล",minimize: "ย่อการนำเข้า",restoreImport: "เปิดหน้าต่างนำเข้าอีกครั้ง",backgroundWarning: "Rows อาจแสดงขณะเขียน การเข้าถึง Table เป้าหมายพร้อมกันอาจรอหรือล้มเหลวเนื่องจาก Lock ฐานข้อมูล Isolation ของ Transaction หรือ Constraint",diff --git a/apps/desktop/src/i18n/locales/tr.ts b/apps/desktop/src/i18n/locales/tr.tsindex 3d73c65f08..f5e0e802c5 100644--- a/apps/desktop/src/i18n/locales/tr.ts+++ b/apps/desktop/src/i18n/locales/tr.ts@@ -6345,6 +6345,7 @@ export default withEnglishFallback({},tableImport: {title: "Tablo Verisi İçe Aktar",+ titleDatabase: "Veri İçe Aktar",target: "Hedef tablo",selectFile: "Dosya Seç",changeFile: "Dosyayı Değiştir",diff --git a/apps/desktop/src/i18n/locales/zh-CN.ts b/apps/desktop/src/i18n/locales/zh-CN.tsindex 77d27a7eb8..f4223e218a 100644--- a/apps/desktop/src/i18n/locales/zh-CN.ts+++ b/apps/desktop/src/i18n/locales/zh-CN.ts@@ -7937,6 +7937,7 @@ export default withEnglishFallback({},tableImport: {title: "导入表数据",+ titleDatabase: "导入数据",minimize: "收起导入窗口",restoreImport: "恢复导入窗口",backgroundWarning: "导入期间目标表可能逐批写入并暂时只显示部分数据;并发读写该表可能因数据库锁、事务隔离或约束而等待、冲突或失败。",diff --git a/apps/desktop/src/i18n/locales/zh-TW.ts b/apps/desktop/src/i18n/locales/zh-TW.tsindex ff2956645b..cb9d7c7ab7 100644--- a/apps/desktop/src/i18n/locales/zh-TW.ts+++ b/apps/desktop/src/i18n/locales/zh-TW.ts@@ -6231,6 +6231,7 @@ export default withEnglishFallback({},tableImport: {title: "匯入資料表資料",+ titleDatabase: "匯入資料",minimize: "最小化匯入視窗",restoreImport: "還原匯入視窗",backgroundWarning: "資料列可能會隨寫入逐步顯示。並行存取目標資料表時,可能因資料庫鎖定、交易隔離或限制條件而等待或失敗。",