Import/Export Subsystem
Pattern
Most dictionaries implement a two-step import:
-
Dry-run: validate and preview the result without persisting changes.
-
Import: apply changes after the operator confirms.
In the UI, many modules implement this pattern via a reusable component:
-
GenericImportExport(src/components/common/generic-import-export.tsx)
This component is driven by an ImportExportConfig that provides:
-
export / dry-run / import API functions,
-
file validation rules (type, size),
-
optional Zod schema validation and normalization,
-
a custom dry-run renderer (module-specific).
Sequence: Import with dry-run, then apply
Some modules return ok, others use valid. GenericImportExport treats either flag as an “import allowed” signal.
|
UX and error states (UI behavior)
-
File validation happens before dry-run (type and size).
-
Dry-run is rerun automatically when import parameters change (example: switching MERGE/REPLACE).
-
Apply/Import is disabled until dry-run returns an allowed status (
okorvalid) and errors are resolved. -
Failures are routed through
useErrorHandlerand displayed as toasts.