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
feat(import): strikethrough preview for skipped columns in field mapping (#12925) (#12959)
lxk955c50cd7230ec7
diff --git a/apps/desktop/src/components/import/TableImportDialog.vue b/apps/desktop/src/components/import/TableImportDialog.vueindex a00cd06585..0ffbdc410d 100644--- a/apps/desktop/src/components/import/TableImportDialog.vue+++ b/apps/desktop/src/components/import/TableImportDialog.vue@@ -950,6 +950,16 @@ function updateMapping(sourceColumn: string, value: any) {};}+function isSourceColumnSkipped(sourceColumn: string | undefined): boolean {+ if (!sourceColumn) return false;+ if (targetMode.value === "create") {+ const target = columnMapping.value[sourceColumn] ?? sourceColumn;+ return !target || !target.trim();+ }+ const target = columnMapping.value[sourceColumn];+ return !target || target === SKIP_VALUE || !target.trim();+}+function mapByPosition() {const currentPreview = preview.value;if (!currentPreview) return;@@ -1825,15 +1835,29 @@ watch(rawProgressPercent, (percent) => {<table class="min-w-full border-separate border-spacing-0 text-xs"><thead class="sticky top-0 bg-background"><tr>- <th v-for="column in preview.columns" :key="column" class="border-b border-r px-2 py-1.5 text-left font-medium">- <span class="block max-w-[140px] truncate">{{ column }}</span>+ <th v-for="column in preview.columns" :key="column" class="border-b border-r px-2 py-1.5 text-left font-medium transition-colors" :class="{ 'text-muted-foreground/60': isSourceColumnSkipped(column) }">+ <span+ class="block max-w-[140px] truncate"+ :class="{ 'line-through text-muted-foreground': isSourceColumnSkipped(column) }"+ :data-column-skipped="isSourceColumnSkipped(column) ? 'true' : undefined"+ :title="isSourceColumnSkipped(column) ? `${column} (${t('tableImport.skipColumn')})` : column"+ >{{ column }}</span+ ></th></tr></thead><tbody><tr v-for="(row, rowIndex) in preview.rows" :key="rowIndex">- <td v-for="(cell, colIndex) in row" :key="colIndex" class="max-w-[180px] border-b border-r px-2 py-1.5 font-mono" :class="{ 'text-muted-foreground': cell === null }">- <span class="block truncate">{{ formatTableImportPreviewCell(cell) }}</span>+ <td+ v-for="(cell, colIndex) in row"+ :key="colIndex"+ class="max-w-[180px] border-b border-r px-2 py-1.5 font-mono transition-colors"+ :class="{+ 'text-muted-foreground': cell === null,+ 'text-muted-foreground/50 bg-muted/20': isSourceColumnSkipped(preview.columns[colIndex]),+ }"+ >+ <span class="block truncate" :class="{ 'line-through': isSourceColumnSkipped(preview.columns[colIndex]) }" :data-cell-skipped="isSourceColumnSkipped(preview.columns[colIndex]) ? 'true' : undefined">{{ formatTableImportPreviewCell(cell) }}</span></td></tr></tbody>diff --git a/apps/desktop/src/components/import/__tests__/TableImportDialog.existingTarget.spec.ts b/apps/desktop/src/components/import/__tests__/TableImportDialog.existingTarget.spec.tsindex 7c45da71ac..274b9afa3a 100644--- a/apps/desktop/src/components/import/__tests__/TableImportDialog.existingTarget.spec.ts+++ b/apps/desktop/src/components/import/__tests__/TableImportDialog.existingTarget.spec.ts@@ -260,7 +260,17 @@ beforeEach(() => {{ name: "name", data_type: "TEXT", nullable: true, is_primary_key: false },]);mocks.listDataTypes.mockClear();- mocks.previewTableImportFile.mockClear();+ mocks.previewTableImportFile.mockReset().mockResolvedValue({+ fileName: "rows.xlsx",+ filePath: "/tmp/rows.xlsx",+ fileType: "excel",+ sizeBytes: 24,+ columns: ["id", "name"],+ rows: [[1, "Alice"]],+ totalRows: 1,+ sourceFingerprint: "rows-xlsx",+ sheets: ["Data"],+ });mocks.importTableFile.mockReset().mockImplementation(async (request, onProgress) => {onProgress({ importId: request.importId, status: "done", rowsImported: 1, totalRows: 1, elapsedMs: 1 });return { importId: request.importId, rowsImported: 1, totalRows: 1, elapsedMs: 1 };@@ -511,7 +521,7 @@ describe("TableImportDialog existing targets", () => {});it("allows selecting update-existing on options step when target has keys even if preview columns are initially unmapped, and guards mapping step", async () => {- mocks.previewTableImportFile.mockResolvedValueOnce({+ mocks.previewTableImportFile.mockResolvedValue({fileName: "unmapped.xlsx",filePath: "/tmp/unmapped.xlsx",fileType: "excel",@@ -728,4 +738,76 @@ describe("TableImportDialog existing targets", () => {const nameSelects = [...document.body.querySelectorAll<HTMLSelectElement>("select")];expect(nameSelects.map((s) => s.value)).toEqual(["__skip__", "__skip__"]);});++ it("renders strikethrough on skipped column header and preview cells in mapping step", async () => {+ i18n.global.locale.value = "en";+ mocks.previewTableImportFile.mockResolvedValueOnce({+ fileName: "preview_strikethrough.csv",+ filePath: "/tmp/preview_strikethrough.csv",+ fileType: "csv",+ sizeBytes: 30,+ columns: ["id", "name"],+ rows: [+ ["101", "Alice"],+ ["102", "Bob"],+ ],+ totalRows: 2,+ sourceFingerprint: "preview_strikethrough",+ });++ await mountDialog({ prefillTable: "existing_target" });+ await selectWorkbook("preview_strikethrough.csv");+ await vi.waitFor(() => expect(buttonContaining("Next")?.disabled).toBe(false));++ buttonContaining("Next")?.click();+ await flushAsyncUpdates();++ const getHeaderSpans = () => [...document.body.querySelectorAll<HTMLElement>("thead th span")];+ const getRowCells = (rowIdx: number) => [...document.body.querySelectorAll<HTMLElement>(`tbody tr:nth-child(${rowIdx}) td span`)];++ // Initially both columns match "id" and "name"+ expect(getHeaderSpans()).toHaveLength(2);+ expect(getHeaderSpans()[0].classList.contains("line-through")).toBe(false);+ expect(getHeaderSpans()[1].classList.contains("line-through")).toBe(false);+ expect(getRowCells(1)[0].classList.contains("line-through")).toBe(false);+ expect(getRowCells(1)[1].classList.contains("line-through")).toBe(false);++ // Skip the second column ("name")+ const selects = [...document.body.querySelectorAll<HTMLSelectElement>("select")];+ expect(selects).toHaveLength(2);+ selects[1].value = "__skip__";+ selects[1].dispatchEvent(new Event("change"));+ await flushAsyncUpdates();++ // Column 0 is still active, Column 1 has strikethrough+ expect(getHeaderSpans()[0].classList.contains("line-through")).toBe(false);+ expect(getHeaderSpans()[1].classList.contains("line-through")).toBe(true);+ expect(getRowCells(1)[0].classList.contains("line-through")).toBe(false);+ expect(getRowCells(1)[1].classList.contains("line-through")).toBe(true);+ expect(getRowCells(2)[0].classList.contains("line-through")).toBe(false);+ expect(getRowCells(2)[1].classList.contains("line-through")).toBe(true);++ // Click "Skip all"+ const skipAllBtn = document.body.querySelector<HTMLButtonElement>('button[data-action="skip-all"]');+ expect(skipAllBtn).toBeTruthy();+ skipAllBtn?.click();+ await flushAsyncUpdates();++ // Both columns now have strikethrough+ expect(getHeaderSpans()[0].classList.contains("line-through")).toBe(true);+ expect(getHeaderSpans()[1].classList.contains("line-through")).toBe(true);+ expect(getRowCells(1)[0].classList.contains("line-through")).toBe(true);+ expect(getRowCells(1)[1].classList.contains("line-through")).toBe(true);++ // Re-map by position+ const mapByPositionBtn = document.body.querySelector<HTMLButtonElement>('button[data-action="map-by-position"]');+ mapByPositionBtn?.click();+ await flushAsyncUpdates();++ // Neither column has strikethrough+ expect(getHeaderSpans()[0].classList.contains("line-through")).toBe(false);+ expect(getHeaderSpans()[1].classList.contains("line-through")).toBe(false);+ expect(getRowCells(1)[0].classList.contains("line-through")).toBe(false);+ expect(getRowCells(1)[1].classList.contains("line-through")).toBe(false);+ });});