Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
Rework the import wizard into a sheet + full-window dialog flow
Damian Legawiec737eb9dedb84
diff --git a/CLAUDE.md b/CLAUDE.mdindex ae43713a85..5ccc5ab7f1 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -41,7 +41,7 @@ Multi-version plans (some phases shipped, some pending):- `5.6-6.0-single-store-promotions-payment-methods.md` — Migrate `Spree::Promotion` + `Spree::PaymentMethod` from multi-store (`has_many :stores` via `spree_promotions_stores` / `spree_payment_methods_stores` join tables) to single-owner `belongs_to :store`, mirroring the 5.5 single-owner Product migration. 5.6 (implemented): `store_id` FK + required-store presence via `Spree::SingleStoreResource`, backfill rake task (loud per-record deprecation on shared records), shared `LegacyMultiStoreSupport` deprecation bridge, deletes the `ResourceController` `store_ids=` seam, deprecates `StoreScopedResource`; multi-store sharing moves to the `spree_multi_store` extension (join tables left intact). 6.0 cleanup: enforce `null: false`, drop join tables + bridges. Paired with `6.0-channels-catalogs-b2b.md`.Pending design work (drafts, no implementation yet):-- `5.6-admin-spa-csv-import.md` — Universal dashboard CSV import over the existing `Spree::Import` pipeline (design finalized). Admin API v3 surface (create via direct-upload signed blob, `complete_mapping`, `retry_failed_rows`, nested failed-rows index, write-scope gating), `client.imports` SDK resource, dashboard-core `ImportButton` (per-context `<Can>` gating) + wizard under `/settings/imports` (new `audit` settings-nav group). Status via API polling — explicitly no ActionCable/Turbo Streams in the SPA; legacy per-row live feed replaced by polled counters + paginated failed-rows table.+- `5.6-admin-spa-csv-import.md` — Universal dashboard CSV import over the existing `Spree::Import` pipeline (implemented). Admin API v3 surface (create via direct-upload signed blob, `complete_mapping`, `retry_failed_rows`, nested failed-rows index, write-scope gating), `client.imports` SDK resource, dashboard-core `ImportButton` (per-context `<Can>` gating, upload Sheet) + full-window wizard dialog driven by an `?import=` search param, with history under `/settings/imports` (new `audit` settings-nav group). Status via API polling — explicitly no ActionCable/Turbo Streams in the SPA; legacy per-row live feed replaced by polled counters + paginated failed-rows table.- `5.5-6.0-resource-translations-api.md` — Admin API v3 translation management + React dashboard for all `Spree.translatable_resources`. Hybrid: embedded `translations` object on resource update + generic dedicated `…/:id/translations` endpoint (one registry-driven controller), self-describing field discovery, advisory server-side staleness. Canonical `{ locale → { field → value } }` shape (consistent with metafield-translations). Cross-record bulk = CSV import/export generalized across the registry (NOT a JSON bulk endpoint — no competitor ships one). Phase 1 (5.5) API; Phase 2 (6.0) coverage read + CSV generalization + staleness + centralized SPA page; Phase 3 folds in metafields.- `5.4-centralized-translations-admin.md` — Centralized Translations admin page under Products, overview grid + bulk CSV import/export- `5.4-metafield-translations.md` — Translate MetafieldDefinition names + Metafield text values (ShortText, LongText, RichText) via Mobility translation tablesdiff --git a/docs/plans/5.6-admin-spa-csv-import.md b/docs/plans/5.6-admin-spa-csv-import.mdindex 8aa1a813af..4123f88d4d 100644--- a/docs/plans/5.6-admin-spa-csv-import.md+++ b/docs/plans/5.6-admin-spa-csv-import.md@@ -33,7 +33,7 @@ This plan brings imports to the SPA as a **universal, registry-driven flow** —- **Secret-key gating: an import is a bulk write.** Mirror `Spree::Export.required_scope` with `Spree::Import.required_scope`, but map every action to the **write** scope of the imported resource (`Spree::Imports::Products` → `write_products`). The index is filtered to the types the key can write. No standalone `write_imports` scope, same reasoning as exports.-- **Route-based wizard under the settings shell, not a modal.** Processing takes minutes; admins must be able to navigate away and come back. The flow lives at `/$storeId/settings/imports/$importId` (mapping → progress → results are states of one route, keyed off `import.status`), plus a `/settings/imports` history page registered in the settings nav under a new **`audit` group** (future home for exports history and audit logs; legacy groups imports with exports/audits too). Exports stayed toast-only because they end in a download; imports end in a report you review.+- **Overlay wizard, not a page** *(revised 2026-07-11 — originally a route under the settings shell)*. The upload step opens in a **Sheet** from the resource page toolbar; on create the wizard (mapping → progress → results, keyed off `import.status`) opens in a **full-window dialog** using the bulk-price-editor shell — the user never leaves the table they were on. The open dialog is driven by an `?import=<prefixed id>` search param (same idiom as the webhooks `delivery` param), so it deep-links and survives refresh; closing mid-processing is safe — the import continues server-side. The `/settings/imports` history page (new **`audit`** settings-nav group, future home for exports history and audit logs) reopens the same dialog on row click; there is **no detail route**.- **Retry failed rows ships in v1.** The dispatcher already re-processes `pending_and_failed` rows on any re-dispatch, so retry is one new state-machine transition (`completed → processing`, guarded on failures existing) + one endpoint + one button on the results screen. No new processing logic.@@ -309,7 +309,7 @@ readonly imports = {### Dashboard-**`ImportButton` (`packages/dashboard-core/src/components/import-button.tsx`)** — sits beside `export-button.tsx`, same toolbar slot. Props: `{ type: ImportType; subject: SubjectName; onCreated: (imp: AdminImport) => void }` — dashboard-core must not know app routes, so navigation is the app's callback (products index passes `navigate({ to: '/$storeId/settings/imports/$importId', ... })`). The button wraps itself in `<Can I="create" a={subject}>` (per-context gating — see Key Decisions). The dialog contains:+**`ImportButton` (`packages/dashboard-core/src/components/import-button.tsx`)** — sits beside `export-button.tsx`, same toolbar slot. Props: `{ type: ImportType; subject: SubjectName; onCreated: (imp: AdminImport) => void }` — dashboard-core must not know app routes or dialogs, so what happens after create is the app's callback (the index pages set the `?import=` search param, which opens the wizard dialog). The button wraps itself in `<Can I="create" a={subject}>` (per-context gating — see Key Decisions) and opens a **Sheet** containing:- CSV dropzone → `useDirectUpload`. **Force `content_type: 'text/csv'` in the presign for `.csv` files** — Windows browsers report `.csv` as `application/vnd.ms-excel` and the model validation rejects it.- Delimiter select (`,` `;` `|` tab — the model's `preferred_delimiter` preference).@@ -333,10 +333,10 @@ export function useImport(id: string) {Plus `useImports()` (history list), `useImportRows(id, params)` (5s `refetchInterval` while the parent import is non-terminal), `useCreateImport()`, `useCompleteMapping(id)`, `useDeleteImport()`.-**Routes + nav:**+**Routes, dialog + nav:**-- `routes/_authenticated/$storeId/settings/imports/index.tsx` — history: `ResourceTable` over `client.imports.list` (number, type, status badge, `completed/failed/total` counts, user, created_at; row click → detail). Registered in `packages/dashboard/src/nav/settings.ts` under a **new `audit` settings-nav group** (`settingsNav.addGroup({ key: 'audit', ... })`, positioned after `team`), entry `{ key: 'settings.imports', path: '/imports', group: 'audit' }` — the group is the future home for exports history and audit logs.-- `routes/_authenticated/$storeId/settings/imports/$importId.tsx` — the wizard, one route switching on `status` per the poll contract:+- `routes/_authenticated/$storeId/settings/imports/index.tsx` — history: `ResourceTable` over `client.imports.list` (number, type, status badge, `completed/failed/total` counts, created_at; row click sets `?import=<id>`, opening the wizard dialog in place). Registered in `packages/dashboard/src/nav/settings.ts` under a **new `audit` settings-nav group** (`settingsNav.addGroup({ key: 'audit', ... })`, positioned after `team`), entry `{ key: 'settings.imports', path: '/imports', group: 'audit' }` — the group is the future home for exports history and audit logs.+- `components/spree/imports/import-wizard-dialog.tsx` — the wizard as a full-window dialog (bulk-price-editor shell: `!inset-3` edge-to-edge `DialogContent`, custom header with type · number, status badge and an X close). Rendered by the products, customers and history pages, opened by their `?import=` search param, switching on `status` per the poll contract:- **Mapping**: step indicator (Map fields → Process → Done, mirroring the legacy wizard); a table of `schema_fields` rows — label + required badge, a `<Select>` of `csv_headers` (+ "Not mapped", with `items` array per the Base UI label rule), the `sample_row` value as muted helper text. "Start import" disabled until every required field is mapped client-side; server 422s render as a banner.- **Processing**: `<Progress>` bar from `(completed + failed) / rows_count`, counter copy ("1,240 of 5,000 rows processed · 12 failed"), indeterminate "Preparing rows…" while `rows_count == 0`, and the failed-rows table streaming in below as failures appear. A **retry pass** is derivable (`completed + failed ≈ rows_count` while `processing`) — show "Retrying failed rows · N remaining" driven by the shrinking `failed_rows_count` instead of the (already full) bar.- **Results**: success/partial summary (completed vs failed counts), paginated failed-rows table (row number, error message, expandable raw `data`), a **"Retry failed rows (N)"** button when `failed_rows_count > 0` (calls `retryFailedRows`; status flips to `processing` and the poll resumes automatically), and an "Import another" back-link. File-level `failed` shows `processing_errors` prominently.diff --git a/packages/dashboard-core/src/components/import-button.tsx b/packages/dashboard-core/src/components/import-button.tsxindex 3f8028071f..c2e867912e 100644--- a/packages/dashboard-core/src/components/import-button.tsx+++ b/packages/dashboard-core/src/components/import-button.tsx@@ -2,13 +2,6 @@ import type { Import, ImportType } from '@spree/admin-sdk'import {Button,cn,- Dialog,- DialogBody,- DialogContent,- DialogDescription,- DialogFooter,- DialogHeader,- DialogTitle,Field,FieldLabel,Select,@@ -16,6 +9,12 @@ import {SelectItem,SelectTrigger,SelectValue,+ Sheet,+ SheetContent,+ SheetDescription,+ SheetFooter,+ SheetHeader,+ SheetTitle,} from '@spree/dashboard-ui'import { DownloadIcon, FileSpreadsheetIcon, UploadIcon } from 'lucide-react'import { useState } from 'react'@@ -43,12 +42,21 @@ interface ImportButtonProps {* scope model. Purely UX; the backend authorizes every request.*/subject: SubjectName- /** Receives the created import (in `mapping` state); the app navigates to the wizard. */+ /**+ * Receives the created import (in `mapping` state). The consumer opens the+ * wizard — typically a full-window dialog driven by an `?import=` search+ * param.+ */onCreated: (imp: Import) => void/** Label shown on the button. Defaults to the translated "Import" action. */label?: string}+/**+ * Toolbar entry point for CSV imports: opens a Sheet with the upload form+ * (file, delimiter, template download). On success the sheet closes and the+ * created import is handed to `onCreated`.+ */export function ImportButton({ type, subject, onCreated, label }: ImportButtonProps) {const { t } = useTranslation()const [open, setOpen] = useState(false)@@ -113,19 +121,19 @@ export function ImportButton({ type, subject, onCreated, label }: ImportButtonPr{label ?? t('admin.actions.import')}</Button>- <Dialog open={open} onOpenChange={handleOpenChange}>- <DialogContent>- <DialogHeader>- <DialogTitle>{t('admin.components.import_button.title')}</DialogTitle>- <DialogDescription>{t('admin.components.import_button.description')}</DialogDescription>- </DialogHeader>+ <Sheet open={open} onOpenChange={handleOpenChange}>+ <SheetContent className="sm:max-w-xl">+ <SheetHeader>+ <SheetTitle>{t('admin.components.import_button.title')}</SheetTitle>+ <SheetDescription>{t('admin.components.import_button.description')}</SheetDescription>+ </SheetHeader>- <DialogBody className="flex flex-col gap-4">+ <div className="flex min-h-0 flex-1 flex-col gap-4 overflow-y-auto p-4">{/* A <label> wrapping the file input: clicking anywhere opens thepicker natively, no JS forwarding needed. */}<labelclassName={cn(- 'flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-border border-dashed bg-muted/40 px-4 py-8 text-center transition-colors hover:bg-muted',+ 'flex cursor-pointer flex-col items-center justify-center gap-2 rounded-md border border-border border-dashed bg-muted/40 px-4 py-10 text-center transition-colors hover:bg-muted',file && 'border-solid',)}onDragOver={(e) => e.preventDefault()}@@ -189,20 +197,30 @@ export function ImportButton({ type, subject, onCreated, label }: ImportButtonPr<DownloadIcon className="size-4" />{t('admin.components.import_button.download_template')}</Button>- </DialogBody>+ </div>- <DialogFooter>- <Button variant="outline" onClick={() => handleOpenChange(false)}>+ <SheetFooter>+ <Button+ type="button"+ variant="outline"+ size="sm"+ onClick={() => handleOpenChange(false)}+ >{t('admin.actions.cancel')}</Button>- <Button onClick={handleSubmit} disabled={!file || createImport.isPending}>+ <Button+ type="button"+ size="sm"+ onClick={handleSubmit}+ disabled={!file || createImport.isPending}+ >{createImport.isPending? t('admin.components.import_button.uploading'): t('admin.components.import_button.submit')}</Button>- </DialogFooter>- </DialogContent>- </Dialog>+ </SheetFooter>+ </SheetContent>+ </Sheet></Can>)}diff --git a/packages/dashboard/e2e/imports.spec.ts b/packages/dashboard/e2e/imports.spec.tsindex 23b8c4a27d..5bb17ef5e2 100644--- a/packages/dashboard/e2e/imports.spec.ts+++ b/packages/dashboard/e2e/imports.spec.ts@@ -11,7 +11,7 @@ function csvFile(rows: string[]) {}}-async function openImportDialog(page: Page, storeId: string) {+async function openImportSheet(page: Page, storeId: string) {await page.goto(PRODUCTS_PATH(storeId))await page.getByRole('button', { name: /^import$/i }).click()await expect(page.getByRole('heading', { name: /import from csv/i })).toBeVisible()@@ -28,7 +28,7 @@ test.describe('csv import', () => {const suffix = Date.now()const goodName = `E2E Imported Product ${suffix}`- await openImportDialog(page, creds.store_id)+ await openImportSheet(page, creds.store_id)// Row 2 has no name and no price — guaranteed row-level failure that// feeds the failed-rows report without failing the whole import.@@ -84,7 +84,7 @@ test.describe('csv import', () => {const creds = await login(page)const suffix = Date.now()- await openImportDialog(page, creds.store_id)+ await openImportSheet(page, creds.store_id)// No `price` column at all — a required schema field stays unmapped.await page@@ -102,8 +102,14 @@ test.describe('csv import', () => {await expect(page.getByRole('button', { name: /start import/i })).toBeDisabled()await expect(page.getByText(/map the required fields to continue/i)).toBeVisible()- // The import history lists the abandoned mapping-state import too.+ // The import history lists the abandoned mapping-state import too, and a+ // row click re-opens the wizard dialog right where the user left off.await page.goto(`/${creds.store_id}/settings/imports`)await expect(page.getByText(/^IM\d+/).first()).toBeVisible({ timeout: 15_000 })+ await page+ .getByText(/^IM\d+/)+ .first()+ .click()+ await expect(page.getByText('Map columns')).toBeVisible({ timeout: 15_000 })})})diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/$importId.tsx b/packages/dashboard/src/components/spree/imports/import-wizard-dialog.tsxsimilarity index 81%rename from packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/$importId.tsxrename to packages/dashboard/src/components/spree/imports/import-wizard-dialog.tsxindex dc23a1da74..ab12b16bb7 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/$importId.tsx+++ b/packages/dashboard/src/components/spree/imports/import-wizard-dialog.tsx@@ -1,5 +1,4 @@import type { Import, ImportRow } from '@spree/admin-sdk'-import { PageHeader } from '@spree/dashboard-core'import {Badge,Button,@@ -8,6 +7,11 @@ import {CardHeader,CardTitle,cn,+ Dialog,+ DialogBody,+ DialogContent,+ DialogHeader,+ DialogTitle,Select,SelectContent,SelectItem,@@ -22,64 +26,106 @@ import {TableHeader,TableRow,} from '@spree/dashboard-ui'-import { createFileRoute, useNavigate } from '@tanstack/react-router'+import { useNavigate } from '@tanstack/react-router'import {AlertTriangleIcon,CheckCircle2Icon,ChevronLeftIcon,ChevronRightIcon,RotateCcwIcon,+ XIcon,} from 'lucide-react'import { useState } from 'react'import { useTranslation } from 'react-i18next'import {- isImportActive,useCompleteMapping,useImport,useImportRows,useRetryFailedRows,} from '@/hooks/use-imports'-import { importTypeIndexPath, importTypeLabel } from '@/lib/import-types'--export const Route = createFileRoute('/_authenticated/$storeId/settings/imports/$importId')({- component: ImportWizardPage,-})+import { importTypeIndexPath, importTypeLabel, isImportActive } from '@/lib/import-types'const NOT_MAPPED = '__not_mapped__'-function ImportWizardPage() {+interface ImportWizardDialogProps {+ /** Prefixed id of the import to drive; `null` keeps the dialog closed. */+ importId: string | null+ onClose: () => void+}++/**+ * Full-window wizard for one import — mapping → progress → results as states+ * of a single edge-to-edge dialog (same shell as the bulk price editor).+ * "Deeper into this thing", not "leave this thing": the page behind keeps its+ * state, and closing mid-processing is safe — the import continues server-side+ * and reopens from the history page (or the same `?import=` URL).+ */+export function ImportWizardDialog({ importId, onClose }: ImportWizardDialogProps) {+ return (+ <Dialog open={!!importId} onOpenChange={(next) => !next && onClose()} modal>+ <DialogContent+ // Edge-to-edge minus a 3-unit gutter — see BulkPriceEditorDialog for+ // why every inset/translate/max is overridden.+ className="!inset-3 !w-auto !max-w-none !translate-x-0 !translate-y-0 flex flex-col p-0"+ style={{ maxHeight: 'none' }}+ showCloseButton={false}+ >+ {importId && <ImportWizard importId={importId} onClose={onClose} />}+ </DialogContent>+ </Dialog>+ )+}++function ImportWizard({ importId, onClose }: { importId: string; onClose: () => void }) {const { t } = useTranslation()- const { importId, storeId } = Route.useParams()const { data: imp, isLoading } = useImport(importId)- if (isLoading || !imp) {- return (- <div className="flex flex-col gap-4 p-4 md:p-6">- <Skeleton className="h-8 w-64" />- <Skeleton className="h-40 w-full" />- </div>- )- }-const showFailedRows =- imp.failed_rows_count > 0 && (isImportActive(imp.status) || imp.status === 'completed')+ !!imp && imp.failed_rows_count > 0 && (isImportActive(imp.status) || imp.status === 'completed')return (- <div className="flex flex-col gap-4 p-4 md:p-6">- <PageHeader- title={`${importTypeLabel(imp.type)} · ${imp.number}`}- backTo={`/${storeId}/settings/imports`}- badges={<StatusBadge status={imp.status} label={t(`admin.imports.status.${imp.status}`)} />}- />-- <StepIndicator status={imp.status} />-- {imp.status === 'mapping' && <MappingStep imp={imp} />}- {isImportActive(imp.status) && <ProcessingCard imp={imp} />}- {imp.status === 'completed' && <ResultsCard imp={imp} storeId={storeId} />}- {imp.status === 'failed' && <FailedCard imp={imp} />}- {showFailedRows && <FailedRowsCard imp={imp} />}- </div>+ <>+ <DialogHeader className="flex flex-row items-center justify-between gap-3 space-y-0 border-b p-3">+ <div className="flex min-w-0 items-center gap-2">+ <DialogTitle className="truncate">+ {imp ? `${importTypeLabel(imp.type)} · ${imp.number}` : t('admin.imports.wizard_title')}+ </DialogTitle>+ {imp && (+ <StatusBadge status={imp.status} label={t(`admin.imports.status.${imp.status}`)} />+ )}+ </div>+ <Button+ type="button"+ size="icon-sm"+ variant="ghost"+ onClick={onClose}+ aria-label={t('admin.actions.close')}+ >+ <XIcon />+ </Button>+ </DialogHeader>++ <DialogBody className="min-h-0 flex-1 overflow-y-auto p-4">+ <div className="mx-auto flex w-full max-w-4xl flex-col gap-4">+ {isLoading || !imp ? (+ <>+ <Skeleton className="h-6 w-64" />+ <Skeleton className="h-40 w-full" />+ </>+ ) : (+ <>+ <StepIndicator status={imp.status} />++ {imp.status === 'mapping' && <MappingStep imp={imp} />}+ {isImportActive(imp.status) && <ProcessingCard imp={imp} />}+ {imp.status === 'completed' && <ResultsCard imp={imp} onClose={onClose} />}+ {imp.status === 'failed' && <FailedCard imp={imp} />}+ {showFailedRows && <FailedRowsCard imp={imp} />}+ </>+ )}+ </div>+ </DialogBody>+ </>)}@@ -101,8 +147,7 @@ function StepIndicator({ status }: { status: string }) {<spanclassName={cn('flex size-5 items-center justify-center rounded-full text-xs',- index < activeIndex && 'bg-primary text-primary-foreground',- index === activeIndex && 'bg-primary text-primary-foreground',+ index <= activeIndex && 'bg-primary text-primary-foreground',index > activeIndex && 'bg-muted text-muted-foreground',)}>@@ -326,7 +371,7 @@ function ProcessingCard({ imp }: { imp: Import }) {// Results / file-level failure// ----------------------------------------------------------------------------function ResultsCard({ imp, storeId }: { imp: Import; storeId: string }) {+function ResultsCard({ imp, onClose }: { imp: Import; onClose: () => void }) {const { t } = useTranslation()const navigate = useNavigate()const retryMutation = useRetryFailedRows(imp.id)@@ -356,7 +401,10 @@ function ResultsCard({ imp, storeId }: { imp: Import; storeId: string }) {</Button>)}<Button- onClick={() => navigate({ to: importTypeIndexPath(imp.type), params: { storeId } })}+ onClick={() => {+ onClose()+ navigate({ to: importTypeIndexPath(imp.type) })+ }}>{t('admin.imports.results.view_records', { type: importTypeLabel(imp.type) })}</Button>diff --git a/packages/dashboard/src/locales/ar.json b/packages/dashboard/src/locales/ar.jsonindex 5289cdc405..6c6faf7b6f 100644--- a/packages/dashboard/src/locales/ar.json+++ b/packages/dashboard/src/locales/ar.json@@ -2608,6 +2608,7 @@"load_failed": "فشل تحميل الفئات. يرجى المحاولة مرة أخرى."},"imports": {+ "wizard_title": "الاستيراد","steps": {"map_fields": "مطابقة الحقول","process_rows": "معالجة الصفوف",diff --git a/packages/dashboard/src/locales/de.json b/packages/dashboard/src/locales/de.jsonindex c1845a1100..5fc8a9e67c 100644--- a/packages/dashboard/src/locales/de.json+++ b/packages/dashboard/src/locales/de.json@@ -2608,6 +2608,7 @@"load_failed": "Kategorien konnten nicht geladen werden. Bitte erneut versuchen."},"imports": {+ "wizard_title": "Import","steps": {"map_fields": "Felder zuordnen","process_rows": "Zeilen verarbeiten",diff --git a/packages/dashboard/src/locales/en.json b/packages/dashboard/src/locales/en.jsonindex f1c1c9b8d0..50a7ccc08b 100644--- a/packages/dashboard/src/locales/en.json+++ b/packages/dashboard/src/locales/en.json@@ -2608,6 +2608,7 @@"load_failed": "Failed to load categories. Please try again."},"imports": {+ "wizard_title": "Import","steps": {"map_fields": "Map fields","process_rows": "Process rows",diff --git a/packages/dashboard/src/locales/fr.json b/packages/dashboard/src/locales/fr.jsonindex f663ede0da..840c199814 100644--- a/packages/dashboard/src/locales/fr.json+++ b/packages/dashboard/src/locales/fr.json@@ -2608,6 +2608,7 @@"load_failed": "Échec du chargement des catégories. Veuillez réessayer."},"imports": {+ "wizard_title": "Import","steps": {"map_fields": "Associer les champs","process_rows": "Traiter les lignes",diff --git a/packages/dashboard/src/locales/pl.json b/packages/dashboard/src/locales/pl.jsonindex 4afbdb178b..51dc95bd08 100644--- a/packages/dashboard/src/locales/pl.json+++ b/packages/dashboard/src/locales/pl.json@@ -2640,6 +2640,7 @@"load_failed": "Nie udało się załadować kategorii. Spróbuj ponownie."},"imports": {+ "wizard_title": "Import","steps": {"map_fields": "Dopasuj pola","process_rows": "Przetwórz wiersze",diff --git a/packages/dashboard/src/locales/zh-CN.json b/packages/dashboard/src/locales/zh-CN.jsonindex df91f4676f..5f834356a4 100644--- a/packages/dashboard/src/locales/zh-CN.json+++ b/packages/dashboard/src/locales/zh-CN.json@@ -2608,6 +2608,7 @@"load_failed": "加载分类失败。请重试。"},"imports": {+ "wizard_title": "导入","steps": {"map_fields": "匹配字段","process_rows": "处理行",diff --git a/packages/dashboard/src/routeTree.gen.ts b/packages/dashboard/src/routeTree.gen.tsindex 443778c207..6730d87a43 100644--- a/packages/dashboard/src/routeTree.gen.ts+++ b/packages/dashboard/src/routeTree.gen.ts@@ -53,7 +53,6 @@ import { Route as AuthenticatedStoreIdSettingsImportsIndexRouteImport } from './import { Route as AuthenticatedStoreIdProductsPriceListsIndexRouteImport } from './routes/_authenticated/$storeId/products/price-lists/index'import { Route as AuthenticatedStoreIdProductsCategoriesIndexRouteImport } from './routes/_authenticated/$storeId/products/categories/index'import { Route as AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRouteImport } from './routes/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'-import { Route as AuthenticatedStoreIdSettingsImportsImportIdRouteImport } from './routes/_authenticated/$storeId/settings/imports/$importId'import { Route as AuthenticatedStoreIdProductsPriceListsNewRouteImport } from './routes/_authenticated/$storeId/products/price-lists/new'import { Route as AuthenticatedStoreIdProductsCategoriesNewRouteImport } from './routes/_authenticated/$storeId/products/categories/new'import { Route as AuthenticatedStoreIdProductsCategoriesCategoryIdRouteImport } from './routes/_authenticated/$storeId/products/categories/$categoryId'@@ -316,12 +315,6 @@ const AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute =path: '/webhooks/$webhookEndpointId',getParentRoute: () => AuthenticatedStoreIdSettingsRoute,} as any)-const AuthenticatedStoreIdSettingsImportsImportIdRoute =- AuthenticatedStoreIdSettingsImportsImportIdRouteImport.update({- id: '/imports/$importId',- path: '/imports/$importId',- getParentRoute: () => AuthenticatedStoreIdSettingsRoute,- } as any)const AuthenticatedStoreIdProductsPriceListsNewRoute =AuthenticatedStoreIdProductsPriceListsNewRouteImport.update({id: '/products/price-lists/new',@@ -389,7 +382,6 @@ export interface FileRoutesByFullPath {'/$storeId/products/categories/$categoryId': typeof AuthenticatedStoreIdProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof AuthenticatedStoreIdProductsCategoriesNewRoute'/$storeId/products/price-lists/new': typeof AuthenticatedStoreIdProductsPriceListsNewRoute- '/$storeId/settings/imports/$importId': typeof AuthenticatedStoreIdSettingsImportsImportIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute'/$storeId/products/categories/': typeof AuthenticatedStoreIdProductsCategoriesIndexRoute'/$storeId/products/price-lists/': typeof AuthenticatedStoreIdProductsPriceListsIndexRoute@@ -437,7 +429,6 @@ export interface FileRoutesByTo {'/$storeId/products/categories/$categoryId': typeof AuthenticatedStoreIdProductsCategoriesCategoryIdRoute'/$storeId/products/categories/new': typeof AuthenticatedStoreIdProductsCategoriesNewRoute'/$storeId/products/price-lists/new': typeof AuthenticatedStoreIdProductsPriceListsNewRoute- '/$storeId/settings/imports/$importId': typeof AuthenticatedStoreIdSettingsImportsImportIdRoute'/$storeId/settings/webhooks/$webhookEndpointId': typeof AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute'/$storeId/products/categories': typeof AuthenticatedStoreIdProductsCategoriesIndexRoute'/$storeId/products/price-lists': typeof AuthenticatedStoreIdProductsPriceListsIndexRoute@@ -489,7 +480,6 @@ export interface FileRoutesById {'/_authenticated/$storeId/products/categories/$categoryId': typeof AuthenticatedStoreIdProductsCategoriesCategoryIdRoute'/_authenticated/$storeId/products/categories/new': typeof AuthenticatedStoreIdProductsCategoriesNewRoute'/_authenticated/$storeId/products/price-lists/new': typeof AuthenticatedStoreIdProductsPriceListsNewRoute- '/_authenticated/$storeId/settings/imports/$importId': typeof AuthenticatedStoreIdSettingsImportsImportIdRoute'/_authenticated/$storeId/settings/webhooks/$webhookEndpointId': typeof AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute'/_authenticated/$storeId/products/categories/': typeof AuthenticatedStoreIdProductsCategoriesIndexRoute'/_authenticated/$storeId/products/price-lists/': typeof AuthenticatedStoreIdProductsPriceListsIndexRoute@@ -541,7 +531,6 @@ export interface FileRouteTypes {| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/price-lists/new'- | '/$storeId/settings/imports/$importId'| '/$storeId/settings/webhooks/$webhookEndpointId'| '/$storeId/products/categories/'| '/$storeId/products/price-lists/'@@ -589,7 +578,6 @@ export interface FileRouteTypes {| '/$storeId/products/categories/$categoryId'| '/$storeId/products/categories/new'| '/$storeId/products/price-lists/new'- | '/$storeId/settings/imports/$importId'| '/$storeId/settings/webhooks/$webhookEndpointId'| '/$storeId/products/categories'| '/$storeId/products/price-lists'@@ -640,7 +628,6 @@ export interface FileRouteTypes {| '/_authenticated/$storeId/products/categories/$categoryId'| '/_authenticated/$storeId/products/categories/new'| '/_authenticated/$storeId/products/price-lists/new'- | '/_authenticated/$storeId/settings/imports/$importId'| '/_authenticated/$storeId/settings/webhooks/$webhookEndpointId'| '/_authenticated/$storeId/products/categories/'| '/_authenticated/$storeId/products/price-lists/'@@ -967,13 +954,6 @@ declare module '@tanstack/react-router' {preLoaderRoute: typeof AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRouteImportparentRoute: typeof AuthenticatedStoreIdSettingsRoute}- '/_authenticated/$storeId/settings/imports/$importId': {- id: '/_authenticated/$storeId/settings/imports/$importId'- path: '/imports/$importId'- fullPath: '/$storeId/settings/imports/$importId'- preLoaderRoute: typeof AuthenticatedStoreIdSettingsImportsImportIdRouteImport- parentRoute: typeof AuthenticatedStoreIdSettingsRoute- }'/_authenticated/$storeId/products/price-lists/new': {id: '/_authenticated/$storeId/products/price-lists/new'path: '/products/price-lists/new'@@ -1019,7 +999,6 @@ interface AuthenticatedStoreIdSettingsRouteChildren {AuthenticatedStoreIdSettingsStoreRoute: typeof AuthenticatedStoreIdSettingsStoreRouteAuthenticatedStoreIdSettingsTaxCategoriesRoute: typeof AuthenticatedStoreIdSettingsTaxCategoriesRouteAuthenticatedStoreIdSettingsIndexRoute: typeof AuthenticatedStoreIdSettingsIndexRoute- AuthenticatedStoreIdSettingsImportsImportIdRoute: typeof AuthenticatedStoreIdSettingsImportsImportIdRouteAuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute: typeof AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRouteAuthenticatedStoreIdSettingsImportsIndexRoute: typeof AuthenticatedStoreIdSettingsImportsIndexRouteAuthenticatedStoreIdSettingsWebhooksIndexRoute: typeof AuthenticatedStoreIdSettingsWebhooksIndexRoute@@ -1053,8 +1032,6 @@ const AuthenticatedStoreIdSettingsRouteChildren: AuthenticatedStoreIdSettingsRouAuthenticatedStoreIdSettingsTaxCategoriesRoute,AuthenticatedStoreIdSettingsIndexRoute:AuthenticatedStoreIdSettingsIndexRoute,- AuthenticatedStoreIdSettingsImportsImportIdRoute:- AuthenticatedStoreIdSettingsImportsImportIdRoute,AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute:AuthenticatedStoreIdSettingsWebhooksWebhookEndpointIdRoute,AuthenticatedStoreIdSettingsImportsIndexRoute:diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/customers/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/customers/index.tsxindex bf68525e69..a18404916b 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/customers/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/customers/index.tsx@@ -40,6 +40,7 @@ import { useState } from 'react'import { Controller, useForm } from 'react-hook-form'import { useTranslation } from 'react-i18next'import { z } from 'zod/v4'+import { ImportWizardDialog } from '@/components/spree/imports/import-wizard-dialog'import { customerGroupAutocompleteProps, useCustomerGroups } from '@/hooks/use-customer-groups'import {useBulkAddCustomersToGroups,@@ -56,9 +57,11 @@ import {import '@/tables/customers'// Adds `?new=1` on top of the standard table search schema so the create sheet-// is deep-linkable (`/customers?new=1`) and back-button friendly.+// is deep-linkable (`/customers?new=1`) and back-button friendly. `import`+// carries the prefixed id of the import wizard dialog open over the table.const customersSearchSchema = resourceSearchSchema.extend({new: z.coerce.boolean().optional(),+ import: z.string().optional(),})export const Route = createFileRoute('/_authenticated/$storeId/customers/')({@@ -186,6 +189,19 @@ function CustomersPage() {})}+ function openImportWizard(id: string) {+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, import: id }) as never })+ }++ function closeImportWizard() {+ navigate({+ search: (prev: Record<string, unknown>) => {+ const { import: _i, ...rest } = prev+ return rest as never+ },+ })+ }+return (<><ResourceTable<Customer>@@ -201,12 +217,7 @@ function CustomersPage() {<ImportButtontype="Spree::Imports::Customers"subject={Subject.Customer}- onCreated={(imp) =>- navigate({- to: '/$storeId/settings/imports/$importId',- params: { storeId, importId: imp.id },- })- }+ onCreated={(imp) => openImportWizard(imp.id)}/><ExportButton type="Spree::Exports::Customers" {...ctx} /><Button size="sm" className="h-[2.125rem]" onClick={openCreate}>@@ -217,6 +228,7 @@ function CustomersPage() {)}/>{isCreating && <NewCustomerSheet open onOpenChange={(o) => !o && closeSheet()} />}+ <ImportWizardDialog importId={search.import ?? null} onClose={closeImportWizard} /></>)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsxindex 26b5d5c6b9..dbe682119d 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/products/index.tsx@@ -37,6 +37,8 @@ import {import { useCallback, useMemo, useState } from 'react'import { useTranslation } from 'react-i18next'import { toast } from 'sonner'+import { z } from 'zod/v4'+import { ImportWizardDialog } from '@/components/spree/imports/import-wizard-dialog'import { categoryAutocompleteProps, useCategories } from '@/hooks/use-categories'import { channelAutocompleteProps, useChannels } from '@/hooks/use-channels'import { useDeleteProduct } from '@/hooks/use-product'@@ -53,8 +55,14 @@ import {} from '@/hooks/use-products'import '@/tables/products'+// `import` carries the prefixed id of the import whose wizard dialog is open+// over the table — deep-linkable and refresh-safe.+const productsSearchSchema = resourceSearchSchema.extend({+ import: z.string().optional(),+})+export const Route = createFileRoute('/_authenticated/$storeId/products/')({- validateSearch: resourceSearchSchema,+ validateSearch: productsSearchSchema,component: ProductsPage,})@@ -67,9 +75,20 @@ type TagsFormValues = { tags: string[] }function ProductsPage() {const { t } = useTranslation()const { storeId } = Route.useParams()- const searchParams = Route.useSearch()+ const searchParams = Route.useSearch() as z.infer<typeof productsSearchSchema>const navigate = useNavigate()+ const openImportWizard = (id: string) =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, import: id }) as never })++ const closeImportWizard = () =>+ navigate({+ search: (prev: Record<string, unknown>) => {+ const { import: _i, ...rest } = prev+ return rest as never+ },+ })+const bulkStatus = useBulkProductStatusUpdate()const bulkAddCategories = useBulkAddProductsToCategories()const bulkRemoveCategories = useBulkRemoveProductsFromCategories()@@ -255,38 +274,36 @@ function ProductsPage() {)return (- <ResourceTable- tableKey="products"- queryKey="products"- queryFn={(params) => adminClient.products.list(params)}- defaultParams={{ expand: ['channels'] }}- searchParams={searchParams}- bulkActions={bulkActions}- rowActions={renderRowActions}- actions={(ctx) => (- <>- <ImportButton- type="Spree::Imports::Products"- subject={Subject.Product}- onCreated={(imp) =>- navigate({- to: '/$storeId/settings/imports/$importId',- params: { storeId, importId: imp.id },- })- }- />- <ExportButton type="Spree::Exports::Products" {...ctx} />- <Button- size="sm"- className="h-[2.125rem]"- onClick={() => navigate({ to: '/$storeId/products/new', params: { storeId } })}- >- <PlusIcon className="size-4" />- {t('admin.pages.products.add_cta')}- </Button>- </>- )}- />+ <>+ <ResourceTable+ tableKey="products"+ queryKey="products"+ queryFn={(params) => adminClient.products.list(params)}+ defaultParams={{ expand: ['channels'] }}+ searchParams={searchParams}+ bulkActions={bulkActions}+ rowActions={renderRowActions}+ actions={(ctx) => (+ <>+ <ImportButton+ type="Spree::Imports::Products"+ subject={Subject.Product}+ onCreated={(imp) => openImportWizard(imp.id)}+ />+ <ExportButton type="Spree::Exports::Products" {...ctx} />+ <Button+ size="sm"+ className="h-[2.125rem]"+ onClick={() => navigate({ to: '/$storeId/products/new', params: { storeId } })}+ >+ <PlusIcon className="size-4" />+ {t('admin.pages.products.add_cta')}+ </Button>+ </>+ )}+ />+ <ImportWizardDialog importId={searchParams.import ?? null} onClose={closeImportWizard} />+ </>)}diff --git a/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/index.tsx b/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/index.tsxindex b9b3ff66f0..346a9e677b 100644--- a/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/index.tsx+++ b/packages/dashboard/src/routes/_authenticated/$storeId/settings/imports/index.tsx@@ -3,28 +3,42 @@ import { adminClient, ResourceTable, resourceSearchSchema } from '@spree/dashboaimport { RowActions, useConfirm, useRowClickBridge } from '@spree/dashboard-ui'import { createFileRoute, useNavigate } from '@tanstack/react-router'import { useTranslation } from 'react-i18next'+import { z } from 'zod/v4'+import { ImportWizardDialog } from '@/components/spree/imports/import-wizard-dialog'import { isImportActive, useDeleteImport } from '@/hooks/use-imports'import '@/tables/imports'+// `import` carries the prefixed id of the import whose wizard dialog is open,+// so the flow is deep-linkable and survives refresh (same pattern as the+// webhooks `delivery` param).+const importsSearchSchema = resourceSearchSchema.extend({+ import: z.string().optional(),+})+export const Route = createFileRoute('/_authenticated/$storeId/settings/imports/')({- validateSearch: resourceSearchSchema,+ validateSearch: importsSearchSchema,component: ImportsPage,})function ImportsPage() {const { t } = useTranslation()- const { storeId } = Route.useParams()- const search = Route.useSearch()+ const search = Route.useSearch() as z.infer<typeof importsSearchSchema>const navigate = useNavigate()const confirm = useConfirm()const deleteMutation = useDeleteImport()- useRowClickBridge('data-import-id', (id: string) =>+ const openWizard = (id: string) =>+ navigate({ search: (prev: Record<string, unknown>) => ({ ...prev, import: id }) as never })++ const closeWizard = () =>navigate({- to: '/$storeId/settings/imports/$importId',- params: { storeId, importId: id },- }),- )+ search: (prev: Record<string, unknown>) => {+ const { import: _i, ...rest } = prev+ return rest as never+ },+ })++ useRowClickBridge('data-import-id', openWizard)async function handleDelete(imp: Import) {const ok = await confirm({@@ -38,34 +52,34 @@ function ImportsPage() {}return (- <ResourceTable<Import>- tableKey="imports"- queryKey="imports"- queryFn={(params) => adminClient.imports.list(params)}- searchParams={search}- rowActions={(imp) => (- <RowActions- actions={[- {- key: 'view',- label: t('admin.actions.view'),- onSelect: () =>- navigate({- to: '/$storeId/settings/imports/$importId',- params: { storeId, importId: imp.id },- }),- },- {- key: 'delete',- destructive: true,- // Deleting mid-processing is refused server-side (422) — the- // pipeline's jobs re-load the record while running.- disabled: deleteMutation.isPending || isImportActive(imp.status),- onSelect: () => handleDelete(imp),- },- ]}- />- )}- />+ <>+ <ResourceTable<Import>+ tableKey="imports"+ queryKey="imports"+ queryFn={(params) => adminClient.imports.list(params)}+ searchParams={search}+ rowActions={(imp) => (+ <RowActions+ actions={[+ {+ key: 'view',+ label: t('admin.actions.view'),+ onSelect: () => openWizard(imp.id),+ },+ {+ key: 'delete',+ destructive: true,+ // Deleting mid-processing is refused server-side (422) — the+ // pipeline's jobs re-load the record while running.+ disabled: deleteMutation.isPending || isImportActive(imp.status),+ onSelect: () => handleDelete(imp),+ },+ ]}+ />+ )}+ />++ <ImportWizardDialog importId={search.import ?? null} onClose={closeWizard} />+ </>)}