Add curl banner to import dialog

This commit is contained in:
Gregory Schier
2024-05-10 13:36:30 -07:00
parent 0f739834c8
commit 6749fa9348
2 changed files with 18 additions and 8 deletions

View File

@@ -17,13 +17,13 @@ export function useImportData() {
const alert = useAlert();
const activeWorkspaceId = useActiveWorkspaceId();
const importData = async () => {
const importData = async (): Promise<boolean> => {
const selected = await open({
filters: [{ name: 'Export File', extensions: ['json', 'yaml', 'sh', 'txt'] }],
multiple: false,
});
if (selected == null) {
return;
return false;
}
const imported: {
@@ -71,6 +71,8 @@ export function useImportData() {
environmentId: imported.environments[0]?.id,
});
}
return true;
};
return useMutation({
@@ -86,12 +88,16 @@ export function useImportData() {
render: ({ hide }) => {
const importAndHide = async () => {
try {
await importData();
const didImport = await importData();
if (!didImport) {
return;
}
resolve();
} catch (err) {
reject(err);
} finally {
hide();
}
hide();
};
return <ImportDataDialog importData={importAndHide} />;
},