Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

Invalidate instead of hard reload

Daniel Hougaardf121f8e828d6
diff --git a/frontend/src/hooks/api/workspace/mutations.tsx b/frontend/src/hooks/api/workspace/mutations.tsx
index 03f0d473d7..5aba02098e 100644
--- a/frontend/src/hooks/api/workspace/mutations.tsx
+++ b/frontend/src/hooks/api/workspace/mutations.tsx
@@ -64,13 +64,13 @@ export const useDeleteGroupFromWorkspace = () => {
};
export const useLeaveProject = () => {
- return useMutation<{}, {}, { workspaceId: string; organizationId: string }>({
+ const queryClient = useQueryClient();
+ return useMutation<{}, {}, { workspaceId: string }>({
mutationFn: ({ workspaceId }) => {
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
},
- onSuccess: (_, { organizationId }) => {
- // Invalidating the query here will cause a permission error, so we won't invalidate any queries here. Instead after leaving the workspace, we will redirect the user to the organization overview page.
- window.location.href = `/org/${organizationId}/overview`;
+ onSuccess: () => {
+ queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace);
}
});
};
diff --git a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
index 81ee311019..edbb78c2e4 100644
--- a/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
+++ b/frontend/src/views/Settings/ProjectSettingsPage/components/DeleteProjectSection/DeleteProjectSection.tsx
@@ -114,9 +114,10 @@ export const DeleteProjectSection = () => {
}
}
+ // If it's actually a no-access member, then we don't really care about the members.
+
await leaveProject.mutateAsync({
- workspaceId: currentWorkspace.id,
- organizationId: currentOrg.id
+ workspaceId: currentWorkspace.id
});
router.push(`/org/${currentOrg.id}/overview`);
@@ -152,7 +153,7 @@ export const DeleteProjectSection = () => {
</Button>
)}
</ProjectPermissionCan>
- {!!isOnlyAdminMember && (
+ {!isOnlyAdminMember && (
<Button
disabled={isMembersLoading || (members && members?.length < 2)}
isLoading={isLeaving}