From 61678fc9ccd6db8a2b598c846c86ba4aa8de8a85 Mon Sep 17 00:00:00 2001 From: James Gatz Date: Thu, 28 Sep 2023 21:49:05 +0200 Subject: [PATCH] Feat/export data improvements (#6598) * checkpoint * wuip * dont call the fetcher * export all data on preferences modal * clear console time * cloud synchronization message in login * do not fetch the project in scratchpad since we don't use it if that's the case * fix hasloggedin storage --- .../ui/components/settings/import-export.tsx | 54 ++- .../insomnia/src/ui/routes/auth.authorize.tsx | 2 +- .../insomnia/src/ui/routes/auth.login.tsx | 328 +++++++++++++++--- .../ui/routes/onboarding.cloud-migration.tsx | 2 +- .../insomnia/src/ui/routes/organization.tsx | 43 ++- packages/insomnia/src/ui/routes/project.tsx | 6 +- 6 files changed, 372 insertions(+), 63 deletions(-) diff --git a/packages/insomnia/src/ui/components/settings/import-export.tsx b/packages/insomnia/src/ui/components/settings/import-export.tsx index d3f5b02d25..d2f0495eca 100644 --- a/packages/insomnia/src/ui/components/settings/import-export.tsx +++ b/packages/insomnia/src/ui/components/settings/import-export.tsx @@ -6,13 +6,17 @@ import { isLoggedIn } from '../../../account/session'; import { getProductName } from '../../../common/constants'; import { docsImportExport } from '../../../common/documentation'; import { exportAllToFile } from '../../../common/export'; +import { exportAllData } from '../../../common/export-all-data'; import { getWorkspaceLabel } from '../../../common/get-workspace-label'; import { strings } from '../../../common/strings'; +import { isScratchpadOrganizationId } from '../../../models/organization'; import { isScratchpad } from '../../../models/workspace'; import { ProjectLoaderData } from '../../routes/project'; import { WorkspaceLoaderData } from '../../routes/workspace'; import { Dropdown, DropdownButton, DropdownItem, DropdownSection, ItemContent } from '../base/dropdown'; import { Link } from '../base/link'; +import { Icon } from '../icon'; +import { showAlert } from '../modals'; import { ExportRequestsModal } from '../modals/export-requests-modal'; import { ImportModal } from '../modals/import-modal'; import { Button } from '../themed-button'; @@ -34,7 +38,7 @@ export const ImportExport: FC = ({ hideSettingsModal }) => { const workspacesFetcher = useFetcher(); useEffect(() => { const isIdleAndUninitialized = workspacesFetcher.state === 'idle' && !workspacesFetcher.data; - if (isIdleAndUninitialized) { + if (isIdleAndUninitialized && organizationId && !isScratchpadOrganizationId(organizationId)) { workspacesFetcher.load(`/organization/${organizationId}/project/${projectId}`); } }, [organizationId, projectId, workspacesFetcher]); @@ -47,6 +51,10 @@ export const ImportExport: FC = ({ hideSettingsModal }) => { exportAllToFile(projectName, workspacesForActiveProject); hideSettingsModal(); }; + + if (!organizationId) { + return null; + } // here we should list all the folders which contain insomnia.*.db files // and have some big red button to overwrite the current data with the backup // and once complete trigger an app restart? @@ -59,7 +67,7 @@ export const ImportExport: FC = ({ hideSettingsModal }) => {

Your format isn't supported? Add Your Own.

-
+
{workspaceData?.activeWorkspace ? isScratchpad(workspaceData.activeWorkspace) ? @@ -93,6 +101,48 @@ export const ImportExport: FC = ({ hideSettingsModal }) => { ) : () } +
+ + + + {({ close }) => ( +
+
+ Continue with cloud synchronization + +
+
+
+

+ By continuing with creating an account in Insomnia, or logging into your existing one, we will activate the automated cloud synchronization capability which will synchronize all of your data to the cloud in an end-to-end encrypted format (E2EE) for which you will be required to enter your secret passphrase, or create a new one. +

+
    +
  • Your data in the cloud is end-to-end encrypted (E2EE) and secure.
  • +
  • With Git Sync your data can be stored on a third party Git repository.
  • +
  • In Scratch Pad your data is always stored locally.
  • +
+
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
+

+ While not needed, you can for portability. +

+
+ +
+
+
+ )} +
+
+
+
); }; diff --git a/packages/insomnia/src/ui/routes/onboarding.cloud-migration.tsx b/packages/insomnia/src/ui/routes/onboarding.cloud-migration.tsx index b0be416543..269e19fa20 100644 --- a/packages/insomnia/src/ui/routes/onboarding.cloud-migration.tsx +++ b/packages/insomnia/src/ui/routes/onboarding.cloud-migration.tsx @@ -222,7 +222,7 @@ export const OnboardingCloudMigration = () => {

{ : 'Log in to Insomnia to sync your data.'} + {isScratchpadOrganizationId(organizationId) ? ( + + ) : null}

=> { + const { organizationId, projectId } = params; + invariant(organizationId, 'Organization ID is required'); const sessionId = getCurrentSessionId(); + if (!sessionId) { await logout(); throw redirect('/auth/login'); } const search = new URL(request.url).searchParams; - const { organizationId } = params; - const { projectId } = params; - invariant(organizationId, 'Organization ID is required'); invariant(projectId, 'projectId parameter is required'); const sortOrder = search.get('sortOrder') || 'modified-desc'; const filter = search.get('filter') || '';