mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 17:26:36 +00:00
feat: resolved role issue in ui
This commit is contained in:
@@ -74,7 +74,7 @@ export const registerProjectRoleRouter = async (server: FastifyZodProvider) => {
|
|||||||
|
|
||||||
server.route({
|
server.route({
|
||||||
method: "PATCH",
|
method: "PATCH",
|
||||||
url: "/:projectSlug/roles/:roleId",
|
url: "/:projectId/roles/:roleId",
|
||||||
config: {
|
config: {
|
||||||
rateLimit: writeLimit
|
rateLimit: writeLimit
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -41,8 +41,11 @@ export const useUpdateProjectRole = () => {
|
|||||||
} = await apiRequest.patch(`/api/v2/workspace/${projectId}/roles/${id}`, dto);
|
} = await apiRequest.patch(`/api/v2/workspace/${projectId}/roles/${id}`, dto);
|
||||||
return role;
|
return role;
|
||||||
},
|
},
|
||||||
onSuccess: (_, { projectId }) => {
|
onSuccess: (_, { projectId, slug }) => {
|
||||||
queryClient.invalidateQueries(roleQueryKeys.getProjectRoles(projectId));
|
queryClient.invalidateQueries(roleQueryKeys.getProjectRoles(projectId));
|
||||||
|
if (slug) {
|
||||||
|
queryClient.invalidateQueries(roleQueryKeys.getProjectRoleBySlug(projectId, slug));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -39,8 +39,8 @@ const conditionsMatcher = buildMongoQueryMatcher({ $glob }, { glob });
|
|||||||
|
|
||||||
export const roleQueryKeys = {
|
export const roleQueryKeys = {
|
||||||
getProjectRoles: (projectId: string) => ["roles", { projectSlug: projectId }] as const,
|
getProjectRoles: (projectId: string) => ["roles", { projectSlug: projectId }] as const,
|
||||||
getProjectRoleBySlug: (projectSlug: string, roleSlug: string) =>
|
getProjectRoleBySlug: (projectId: string, roleSlug: string) =>
|
||||||
["roles", { projectSlug, roleSlug }] as const,
|
["roles", { projectId, roleSlug }] as const,
|
||||||
getOrgRoles: (orgId: string) => ["org-roles", { orgId }] as const,
|
getOrgRoles: (orgId: string) => ["org-roles", { orgId }] as const,
|
||||||
getOrgRole: (orgId: string, roleId: string) => [{ orgId, roleId }, "org-role"] as const,
|
getOrgRole: (orgId: string, roleId: string) => [{ orgId, roleId }, "org-role"] as const,
|
||||||
getUserOrgPermissions: ({ orgId }: TGetUserOrgPermissionsDTO) =>
|
getUserOrgPermissions: ({ orgId }: TGetUserOrgPermissionsDTO) =>
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ export const RolePage = withProjectPermission(
|
|||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
const projectId = currentWorkspace?.id || "";
|
const projectId = currentWorkspace?.id || "";
|
||||||
|
|
||||||
const { data } = useGetProjectRoleBySlug(currentWorkspace?.slug ?? "", roleSlug as string);
|
const { data } = useGetProjectRoleBySlug(projectId, roleSlug as string);
|
||||||
|
|
||||||
const { mutateAsync: deleteProjectRole } = useDeleteProjectRole();
|
const { mutateAsync: deleteProjectRole } = useDeleteProjectRole();
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ export const RoleDetailsSection = ({ roleSlug, handlePopUpOpen }: Props) => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const { currentWorkspace } = useWorkspace();
|
const { currentWorkspace } = useWorkspace();
|
||||||
const { data } = useGetProjectRoleBySlug(currentWorkspace?.slug ?? "", roleSlug as string);
|
const { data } = useGetProjectRoleBySlug(currentWorkspace?.id ?? "", roleSlug as string);
|
||||||
|
|
||||||
const isCustomRole = !["admin", "member", "viewer", "no-access"].includes(data?.slug ?? "");
|
const isCustomRole = !["admin", "member", "viewer", "no-access"].includes(data?.slug ?? "");
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -48,7 +48,7 @@ export const RolePermissionsSection = ({ roleSlug, isDisabled }: Props) => {
|
|||||||
const { popUp, handlePopUpToggle } = usePopUp(["createPolicy"] as const);
|
const { popUp, handlePopUpToggle } = usePopUp(["createPolicy"] as const);
|
||||||
const projectId = currentWorkspace?.id || "";
|
const projectId = currentWorkspace?.id || "";
|
||||||
const { data: role, isLoading } = useGetProjectRoleBySlug(
|
const { data: role, isLoading } = useGetProjectRoleBySlug(
|
||||||
currentWorkspace?.slug ?? "",
|
currentWorkspace?.id ?? "",
|
||||||
roleSlug as string
|
roleSlug as string
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user