Fix duplicate import and gate overwrite/skip on database selection#2964
Fix duplicate import and gate overwrite/skip on database selection#2964premtsd-code wants to merge 1 commit intomainfrom
Conversation
- Merge duplicate Layout/Typography import in table +page.svelte - Only show overwrite/skip checkboxes in migration wizard when Databases resource is selected
Greptile SummaryThis PR fixes a duplicate
Confidence Score: 4/5Safe to merge after fixing the stale import-options state in the migration wizard. One P1 bug: importOverwrite/importSkip are never cleared when the user unchecks Databases, so stale true values can be spread into migration API calls unexpectedly. The CSV import change in +page.svelte is clean and correct. wizard.svelte — stale importOverwrite/importSkip state needs to be reset when $formData.databases.root becomes false.
|
| Filename | Overview |
|---|---|
| src/routes/(console)/project-[region]-[project]/databases/database-[database]/table-[table]/+page.svelte | Fixes duplicate import, adds an import-options Dialog (overwrite/skip) before CSV import starts. Logic is clean: onSelect stores pending state, startImport reads it and resets on completion. trackError is preserved. |
| src/routes/(console)/project-[region]-[project]/settings/migrations/(import)/wizard.svelte | Gates the overwrite/skip UI behind database selection, but importOverwrite/importSkip local state is never reset when $formData.databases.root changes back to false — stale values are still spread into all migration API calls. |
Reviews (1): Last reviewed commit: "Fix duplicate import and gate overwrite/..." | Re-trigger Greptile
| {#if $formData.databases.root} | ||
| <Fieldset legend="Import options"> | ||
| <Layout.Stack gap="m"> | ||
| <Selector.Checkbox | ||
| size="s" | ||
| checked={importOverwrite} | ||
| on:change={(e) => { | ||
| importOverwrite = e.detail; | ||
| if (e.detail) importSkip = false; | ||
| }} | ||
| label="Overwrite existing documents" | ||
| description="Documents with matching IDs will be updated with the imported data." /> | ||
| <Selector.Checkbox | ||
| size="s" | ||
| checked={importSkip} | ||
| on:change={(e) => { | ||
| importSkip = e.detail; | ||
| if (e.detail) importOverwrite = false; | ||
| }} | ||
| label="Skip existing documents" | ||
| description="Documents with matching IDs will be silently skipped." /> | ||
| </Layout.Stack> | ||
| </Fieldset> | ||
| {/if} |
There was a problem hiding this comment.
Stale import options sent when databases is deselected
importOverwrite and importSkip are local variables that persist even when the "Import options" fieldset is hidden. If a user:
- Selects Databases → enables "Overwrite existing documents" (sets
importOverwrite = true) - Then unchecks Databases (
$formData.databases.rootbecomesfalse) - Finishes the wizard
The importOptions object is still constructed with the stale importOverwrite: true and spread into every migration API call, sending unintended overwrite/skip flags to the backend even though no databases are being migrated.
Reset both values when databases is deselected, e.g. by deriving them reactively:
$: effectiveOverwrite = $formData.databases.root ? importOverwrite : false;
$: effectiveSkip = $formData.databases.root ? importSkip : false;
const importOptions = {
overwrite: effectiveOverwrite,
skip: effectiveSkip
};
Summary
Test plan