Skip to content

Commit

Permalink
Fix deleting a workspace not updating the view (Kong#6850)
Browse files Browse the repository at this point in the history
  • Loading branch information
gatzjames authored and jackkav committed Mar 13, 2024
1 parent f829009 commit d5854eb
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 26 deletions.
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/insomnia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@
"react-aria": "3.23.1",
"react-aria-components": "^1.0.0-alpha.6",
"react-dom": "^18.2.0",
"react-router-dom": "^6.14.1",
"react-router-dom": "^6.19.0",
"react-stately": "3.21.0",
"react-use": "^17.4.0",
"reselect": "^4.1.5",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export const InsomniaEventStreamProvider: FC<PropsWithChildren> = ({ children })
method: 'POST',
});
} else if (event.type === 'FileDeleted' && event.team === organizationId && event.project === remoteId) {
revalidate();
syncProjectsFetcher.submit({}, {
action: `/organization/${organizationId}/sync-projects`,
method: 'POST',
});
} else if (['BranchDeleted', 'FileChanged'].includes(event.type) && event.team === organizationId && event.project === remoteId) {
syncDataFetcher.submit({}, {
method: 'POST',
Expand Down
1 change: 1 addition & 0 deletions packages/insomnia/src/ui/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ const router = createMemoryRouter(
{
path: 'onboarding/*',
element: <Onboarding />,
errorElement: <ErrorRoute />,
},
{
path: 'onboarding/migrate',
Expand Down
3 changes: 2 additions & 1 deletion packages/insomnia/src/ui/routes/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@ export const ErrorRoute: FC = () => {
return err?.message || 'Unknown error';
};
const getErrorStack = (err: any) => {
if (isRouteErrorResponse(err)) {
if ('error' in err) {
return err.error?.stack;
}

return err?.stack;
};

Expand Down
8 changes: 5 additions & 3 deletions packages/insomnia/src/ui/routes/remote-collections.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionFunction, LoaderFunction } from 'react-router-dom';
import { ActionFunction, LoaderFunction, redirect } from 'react-router-dom';

import { database, Operation } from '../../common/database';
import { isNotNullOrUndefined } from '../../common/misc';
Expand Down Expand Up @@ -267,7 +267,9 @@ export const syncDataLoader: LoaderFunction = async ({ params }): Promise<SyncDa
};

export const checkoutBranchAction: ActionFunction = async ({ request, params }) => {
const { workspaceId } = params;
const { organizationId, projectId, workspaceId } = params;
invariant(typeof organizationId === 'string', 'Organization Id is required');
invariant(typeof projectId === 'string', 'Project Id is required');
invariant(typeof workspaceId === 'string', 'Workspace Id is required');
const formData = await request.formData();
const branch = formData.get('branch');
Expand All @@ -285,7 +287,7 @@ export const checkoutBranchAction: ActionFunction = async ({ request, params })
};
}

return {};
return redirect(`/organization/${organizationId}/project/${projectId}/workspace/${workspaceId}/debug`);
};

export const mergeBranchAction: ActionFunction = async ({ request, params }) => {
Expand Down
6 changes: 2 additions & 4 deletions packages/insomnia/src/ui/routes/workspace.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react';
import { LoaderFunction, Outlet, useLoaderData } from 'react-router-dom';
import { LoaderFunction, Outlet } from 'react-router-dom';

import { isLoggedIn } from '../../account/session';
import { SortOrder } from '../../common/constants';
Expand Down Expand Up @@ -256,9 +256,7 @@ export const workspaceLoader: LoaderFunction = async ({
};

const WorkspaceRoute = () => {
const workspaceData = useLoaderData() as WorkspaceLoaderData;
const branch = workspaceData.activeWorkspaceMeta.cachedGitRepositoryBranch;
return <Outlet key={branch} />;
return <Outlet />;
};

export default WorkspaceRoute;

0 comments on commit d5854eb

Please sign in to comment.