From b4d0730158c7bed6be33dd41485cf2bef4bc734f Mon Sep 17 00:00:00 2001 From: James Gatz Date: Fri, 11 Nov 2022 12:31:09 +0100 Subject: [PATCH] Fix/delete remote project redirect (#5403) * return an empty list if the project doesn't exist * display the sync dropdown only for remote collections * update sync dropdown styles for disconnected collections * fix refetch the backend project on deletion --- .../ui/components/dropdowns/sync-dropdown.tsx | 16 ++++++++++++++-- .../ui/components/modals/sync-delete-modal.tsx | 3 ++- .../src/ui/routes/remote-collections.tsx | 6 ++---- packages/insomnia/src/ui/routes/root.tsx | 2 +- 4 files changed, 19 insertions(+), 8 deletions(-) diff --git a/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx b/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx index 5d89b3e976..b0a7a97561 100644 --- a/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx +++ b/packages/insomnia/src/ui/components/dropdowns/sync-dropdown.tsx @@ -327,10 +327,22 @@ export const SyncDropdown: FC = ({ vcs, workspace, project }) => { if (!vcs.hasBackendProject()) { return (
- refreshVCSAndRefetchRemote()}> - + refreshVCSAndRefetchRemote()} + > + Setup Sync + {syncMenuHeader} {remoteBackendProjects.length === 0 && ( (({ vcs } try { await interceptAccessError({ action: 'delete', - callback: () => vcs.archiveProject(), + callback: async () => await vcs.archiveProject(), resourceName: state.workspaceName, resourceType: strings.collection.singular.toLowerCase(), }); modalRef.current?.hide(); + state.onHide?.(); } catch (err) { setState(state => ({ ...state, diff --git a/packages/insomnia/src/ui/routes/remote-collections.tsx b/packages/insomnia/src/ui/routes/remote-collections.tsx index 7f75659015..72d9c81c81 100644 --- a/packages/insomnia/src/ui/routes/remote-collections.tsx +++ b/packages/insomnia/src/ui/routes/remote-collections.tsx @@ -48,11 +48,9 @@ export const remoteCollectionsLoader: LoaderFunction = async ({ params }): Promi const { projectId } = params; invariant(typeof projectId === 'string', 'Project Id is required'); - const project = await models.project.getById(projectId); - - invariant(project, 'Project not found'); - try { + const project = await models.project.getById(projectId); + invariant(project, 'Project not found'); const vcs = getVCS(); invariant(vcs, 'VCS is not defined'); diff --git a/packages/insomnia/src/ui/routes/root.tsx b/packages/insomnia/src/ui/routes/root.tsx index bf27df07fe..b9f1682fea 100644 --- a/packages/insomnia/src/ui/routes/root.tsx +++ b/packages/insomnia/src/ui/routes/root.tsx @@ -117,7 +117,7 @@ const WorkspaceNavigation: FC = () => { {isDesign(activeWorkspace) && } {isDesign(activeWorkspace) && gitVCS && } - {isCollection(activeWorkspace) && vcs && } + {isCollection(activeWorkspace) && isRemoteProject(activeProject) && vcs && } ); };