mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-09-22 13:39:35 +00:00
Invalidate instead of hard reload
This commit is contained in:
@@ -64,13 +64,13 @@ export const useDeleteGroupFromWorkspace = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const useLeaveProject = () => {
|
export const useLeaveProject = () => {
|
||||||
return useMutation<{}, {}, { workspaceId: string; organizationId: string }>({
|
const queryClient = useQueryClient();
|
||||||
|
return useMutation<{}, {}, { workspaceId: string }>({
|
||||||
mutationFn: ({ workspaceId }) => {
|
mutationFn: ({ workspaceId }) => {
|
||||||
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
|
return apiRequest.delete(`/api/v1/workspace/${workspaceId}/leave`);
|
||||||
},
|
},
|
||||||
onSuccess: (_, { organizationId }) => {
|
onSuccess: () => {
|
||||||
// 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.
|
queryClient.invalidateQueries(workspaceKeys.getAllUserWorkspace);
|
||||||
window.location.href = `/org/${organizationId}/overview`;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -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({
|
await leaveProject.mutateAsync({
|
||||||
workspaceId: currentWorkspace.id,
|
workspaceId: currentWorkspace.id
|
||||||
organizationId: currentOrg.id
|
|
||||||
});
|
});
|
||||||
|
|
||||||
router.push(`/org/${currentOrg.id}/overview`);
|
router.push(`/org/${currentOrg.id}/overview`);
|
||||||
@@ -152,7 +153,7 @@ export const DeleteProjectSection = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
)}
|
)}
|
||||||
</ProjectPermissionCan>
|
</ProjectPermissionCan>
|
||||||
{!!isOnlyAdminMember && (
|
{!isOnlyAdminMember && (
|
||||||
<Button
|
<Button
|
||||||
disabled={isMembersLoading || (members && members?.length < 2)}
|
disabled={isMembersLoading || (members && members?.length < 2)}
|
||||||
isLoading={isLeaving}
|
isLoading={isLeaving}
|
||||||
|
|||||||
Reference in New Issue
Block a user