From 59d136fcf2b592dd7da4bf849f10e7b90311f166 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=5FMr=E4=B8=B6s=20=E3=82=9B=F0=9F=98=81=C2=AE?= <31917567+ma123456mai@users.noreply.github.com> Date: Sat, 26 Sep 2026 22:20:55 +0800 Subject: [PATCH] feat(import): collapsible import window with background progress --- .../components/import/TableImportDialog.vue | 138 +++++++++++++++++- .../TableImportDialog.batchSelection.spec.ts | 53 +++++++ .../ui/dialog/DialogScrollContent.vue | 11 +- apps/desktop/src/i18n/locales/en.ts | 3 + apps/desktop/src/i18n/locales/es.ts | 3 + apps/desktop/src/i18n/locales/it.ts | 3 + apps/desktop/src/i18n/locales/ja.ts | 3 + apps/desktop/src/i18n/locales/ko.ts | 3 + apps/desktop/src/i18n/locales/pt-BR.ts | 3 + apps/desktop/src/i18n/locales/ru.ts | 3 + apps/desktop/src/i18n/locales/zh-CN.ts | 3 + apps/desktop/src/i18n/locales/zh-TW.ts | 3 + 12 files changed, 217 insertions(+), 12 deletions(-) diff --git a/apps/desktop/src/components/import/TableImportDialog.vue b/apps/desktop/src/components/import/TableImportDialog.vue index 1955634835..e44b4eb04c 100644 --- a/apps/desktop/src/components/import/TableImportDialog.vue +++ b/apps/desktop/src/components/import/TableImportDialog.vue @@ -1,5 +1,5 @@ diff --git a/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts b/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts index bd09753469..bf4121bb43 100644 --- a/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts +++ b/apps/desktop/src/components/import/__tests__/TableImportDialog.batchSelection.spec.ts @@ -254,6 +254,24 @@ afterEach(() => { }); describe("TableImportDialog batch selection", () => { + it("lets the import setup dialog be minimized and restored before import starts", async () => { + await mountDialog(); + expect(button("Next").disabled).toBe(false); + document.body.querySelector('button[aria-label="Minimize import"]')!.click(); + await flushAsyncUpdates(); + + expect(document.body.querySelector('button[aria-label="Restore import"]')).toBeTruthy(); + expect(document.body.querySelector('button[aria-label="Next"]')).toBeNull(); + expect(document.body.textContent).toContain("Ready to import"); + expect(document.body.textContent).not.toContain("Writing data"); + + document.body.querySelector('button[aria-label="Restore import"]')!.click(); + await flushAsyncUpdates(); + expect(button("Next").disabled).toBe(false); + expect(document.body.querySelector('button[aria-label="Minimize import"]')).toBeTruthy(); + expect(mocks.importTableFile).not.toHaveBeenCalled(); + }); + it("keeps every worksheet selected by default and imports them in workbook order", async () => { await mountDialog(); for (const name of ["rows_First", "rows_Second", "rows_Third"]) expect(taskCheckbox(name).checked).toBe(true); @@ -383,6 +401,41 @@ describe("TableImportDialog batch selection", () => { expect(document.body.textContent).toContain("Import complete"); }); + it("keeps the import and its progress active while minimized, then restores the same dialog state", async () => { + let finish!: (summary: TableImportSummary) => void; + mocks.importTableFile.mockImplementation((request, onProgress) => { + onProgress({ importId: request.importId, status: "running", phase: "writing", rowsImported: 1, totalRows: 2, elapsedMs: 1 }); + return new Promise((resolve) => { + finish = resolve; + }); + }); + await mountDialog(); + await selectTask("rows_Second", false); + await selectTask("rows_Third", false); + await startImport(); + + expect(mocks.importTableFile).toHaveBeenCalledTimes(1); + const minimizeButton = document.body.querySelector('button[aria-label="Minimize import"]'); + expect(minimizeButton).toBeTruthy(); + minimizeButton!.click(); + await flushAsyncUpdates(); + + expect(document.body.querySelector('button[aria-label="Minimize import"]')).toBeNull(); + expect(document.body.textContent).toContain("Writing data"); + expect(document.body.textContent).toMatch(/\d+%/); + expect(mocks.importTableFile).toHaveBeenCalledTimes(1); + + document.body.querySelector('button[aria-label="Restore import"]')!.click(); + await flushAsyncUpdates(); + expect(document.body.querySelector('button[aria-label="Minimize import"]')).toBeTruthy(); + expect(document.body.textContent).toContain("1 / 2"); + expect(taskCheckbox("rows_First").disabled).toBe(true); + + finish({ importId: "finished-import", rowsImported: 2, totalRows: 2, elapsedMs: 2 }); + await flushAsyncUpdates(); + expect(document.body.textContent).toContain("Import complete"); + }); + it("uses selected source bytes when the selected worksheet has no exact row count", async () => { mocks.previewTableImportFile.mockImplementation((_source, options) => Promise.resolve({ ...workbookPreview(options.parseOptions.sheetName || "First"), totalRowsExact: false })); let finish!: () => void; diff --git a/apps/desktop/src/components/ui/dialog/DialogScrollContent.vue b/apps/desktop/src/components/ui/dialog/DialogScrollContent.vue index 4ea4e77312..c44bee862a 100644 --- a/apps/desktop/src/components/ui/dialog/DialogScrollContent.vue +++ b/apps/desktop/src/components/ui/dialog/DialogScrollContent.vue @@ -12,17 +12,20 @@ defineOptions({ inheritAttrs: false, }); -const props = defineProps(); +const props = withDefaults(defineProps(), { + showOverlay: true, + showCloseButton: true, +}); const emits = defineEmits(); -const delegatedProps = reactiveOmit(props, "class"); +const delegatedProps = reactiveOmit(props, "class", "showOverlay", "showCloseButton"); const forwarded = useForwardPropsEmits(delegatedProps, emits);