Skip to content

Commit da41075

Browse files
authored
Allow exporting all data from settings on login view (#7702)
1 parent 0027958 commit da41075

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

packages/insomnia/src/ui/components/settings/import-export.tsx

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,46 @@ export const ImportExport: FC<Props> = ({ hideSettingsModal }) => {
275275
const hasUntrackedProjects = untrackedProjects.length > 0;
276276
const showImportToProject = !isScratchPadWorkspace;
277277
if (!isScratchPadWorkspace && !isLoggedIn) {
278-
return <p>There is no active project. Create a new project to import or export data.</p>;
278+
return <Button
279+
className="px-4 py-1 font-semibold border border-solid border-[--hl-md] flex items-center justify-center gap-2 aria-pressed:bg-[--hl-sm] rounded-sm text-[--color-font] hover:bg-[--hl-xs] focus:ring-inset ring-1 ring-transparent focus:ring-[--hl-md] transition-all text-sm"
280+
onPress={async () => {
281+
const { filePaths, canceled } = await window.dialog.showOpenDialog({
282+
properties: ['openDirectory', 'createDirectory', 'promptToCreate'],
283+
buttonLabel: 'Select',
284+
title: 'Export All Insomnia Data',
285+
});
286+
287+
if (canceled) {
288+
return;
289+
}
290+
291+
const [dirPath] = filePaths;
292+
293+
try {
294+
dirPath && await exportAllData({
295+
dirPath,
296+
});
297+
} catch (e) {
298+
showAlert({
299+
title: 'Export Failed',
300+
message: 'An error occurred while exporting data. Please try again.',
301+
});
302+
console.error(e);
303+
}
304+
305+
showAlert({
306+
title: 'Export Complete',
307+
message: 'All your data have been successfully exported',
308+
});
309+
window.main.trackSegmentEvent({
310+
event: SegmentEvent.exportAllCollections,
311+
});
312+
}}
313+
aria-label='Export all data'
314+
>
315+
<Icon icon="file-export" />
316+
<span>Export all data {`(${workspaceCount} files)`}</span>
317+
</Button>;
279318
}
280319

281320
return (

0 commit comments

Comments
 (0)