Skip to content

Add useImportConfig hook - #215

Merged
gcgoncalves merged 3 commits into
mainfrom
feat/import-export-import-hook
Nov 6, 2026
Merged

gcgoncalves merged 3 commits into
mainfrom
feat/import-export-import-hook

Conversation

@gcgoncalves

Copy link
Copy Markdown
Contributor

@gcgoncalves
gcgoncalves added this pull request to stack #211 November 2, 2026 15:32
Comment thread src/hooks/useImportConfig.ts Outdated
(signal) => importExportApi.importConfig({ ...opts, data, dryRun: false }, signal),
(value) => {
setResult(value);
toast.success(intl.formatMessage({ id: "importExport.import.success" }, value.progress));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The backend returns 200 with status “completed” even when entities fail, so a fully failed import shows a success toast. During a restore, this reports configuration as applied when it is not.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good point, I'll remove the toast entirely from the hook, leaving the component that invokes it to handle feedback providing.

Comment thread src/hooks/useImportConfig.ts Outdated
const intl = useIntl();
const { hasPermission } = useAuth();
const canImport = hasPermission("admin.import");
const canPreview = hasPermission("admin.system_config");

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Preview needs MCPGATEWAY_ADMIN_API_ENABLED (default false), so it returns an unexplained 404.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, we should avoid /admin endpoints, I'll remove it from the BFF for now. We have a dry-run option on the import endpoint, I think we can use that instead.

@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch 5 times, most recently from 99bfdeb to 1c420de Compare November 3, 2026 12:03
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch from 1c420de to 849723c Compare November 3, 2026 17:00
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-export-hook branch from c70db22 to 88eb500 Compare November 3, 2026 17:03
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch 4 times, most recently from cd65a84 to d62312a Compare November 5, 2026 10:54
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch from d62312a to c8b994b Compare November 5, 2026 11:18
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-export-hook branch 2 times, most recently from e7c4f68 to 9e3a7ff Compare November 5, 2026 11:46
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch 2 times, most recently from d398fc1 to 24f601e Compare November 5, 2026 11:52
Base automatically changed from feat/import-export-export-hook to main November 5, 2026 11:54
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch from 24f601e to 229b1dc Compare November 5, 2026 11:54

@vishu-bh vishu-bh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

implementation looks solid.
One edge case to check.

Comment thread src/hooks/useImportConfig.ts Outdated
async (file: File) => {
reset();
try {
setData(await parseImportFile(file));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Selecting slow file A and then file B lets A finish last and replace B, so the next import can send the wrong configuration. Resetting during File.text() also restores the discarded file when its read completes. Please invalidate pending reads on reset/new selection and guard both data and error updates with a generation token. Add regression tests for these sequences.

@gcgoncalves
gcgoncalves requested a review from vishu-bh November 5, 2026 16:35
@gcgoncalves
gcgoncalves removed this pull request from stack #211 November 5, 2026 16:35
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
Signed-off-by: Gabriel Costa <gabrielcg@proton.me>
@gcgoncalves
gcgoncalves force-pushed the feat/import-export-import-hook branch from bf896f2 to c3e7852 Compare November 5, 2026 16:35

@vishu-bh vishu-bh left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 🚀

@gcgoncalves
gcgoncalves merged commit d67c312 into main Nov 6, 2026
4 checks passed
@gcgoncalves
gcgoncalves deleted the feat/import-export-import-hook branch November 6, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants