mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-21 05:00:56 +00:00
refactor: streamline modal close handlers and completion callbacks across various components
This commit is contained in:
+7
-11
@@ -127,17 +127,13 @@ export const MemberRbacSection = ({ projectMember, onOpenUpgradeModal }: Props)
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await updateMembershipRole.mutateAsync({
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
roleForm.reset(undefined, { keepValues: true });
|
||||
} catch {
|
||||
createNotification({ text: "Failed to update role", type: "error" });
|
||||
}
|
||||
await updateMembershipRole.mutateAsync({
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
roleForm.reset(undefined, { keepValues: true });
|
||||
};
|
||||
|
||||
if (isRolesLoading)
|
||||
|
||||
+6
-10
@@ -114,16 +114,12 @@ export const IdentityRoleModify = ({ identityProjectMembership }: Props) => {
|
||||
};
|
||||
});
|
||||
|
||||
try {
|
||||
await updateIdentityWorkspaceRole.mutateAsync({
|
||||
projectId,
|
||||
identityId: identityProjectMembership.identity.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
} catch {
|
||||
createNotification({ text: "Failed to update roles", type: "error" });
|
||||
}
|
||||
await updateIdentityWorkspaceRole.mutateAsync({
|
||||
projectId,
|
||||
identityId: identityProjectMembership.identity.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
};
|
||||
|
||||
if (isRolesLoading)
|
||||
|
||||
+31
-36
@@ -55,42 +55,37 @@ export const MemberRoleDetailsSection = ({
|
||||
|
||||
const handleRoleDelete = async () => {
|
||||
const { id } = popUp?.deleteRole?.data as TProjectRole;
|
||||
try {
|
||||
const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
|
||||
await updateUserWorkspaceRole({
|
||||
projectId,
|
||||
roles: updatedRoles.map(
|
||||
({
|
||||
role,
|
||||
customRoleSlug,
|
||||
isTemporary,
|
||||
temporaryMode,
|
||||
temporaryRange,
|
||||
temporaryAccessStartTime,
|
||||
temporaryAccessEndTime
|
||||
}) => ({
|
||||
role: role === "custom" ? customRoleSlug : role,
|
||||
...(isTemporary
|
||||
? {
|
||||
isTemporary,
|
||||
temporaryMode,
|
||||
temporaryRange,
|
||||
temporaryAccessStartTime,
|
||||
temporaryAccessEndTime
|
||||
}
|
||||
: {
|
||||
isTemporary
|
||||
})
|
||||
})
|
||||
),
|
||||
membershipId: membershipDetails.id
|
||||
});
|
||||
createNotification({ type: "success", text: "Successfully removed role" });
|
||||
handlePopUpClose("deleteRole");
|
||||
} catch (err) {
|
||||
console.log(err);
|
||||
createNotification({ type: "error", text: "Failed to delete role" });
|
||||
}
|
||||
const updatedRoles = membershipDetails?.roles?.filter((el) => el.id !== id);
|
||||
await updateUserWorkspaceRole({
|
||||
projectId,
|
||||
roles: updatedRoles.map(
|
||||
({
|
||||
role,
|
||||
customRoleSlug,
|
||||
isTemporary,
|
||||
temporaryMode,
|
||||
temporaryRange,
|
||||
temporaryAccessStartTime,
|
||||
temporaryAccessEndTime
|
||||
}) => ({
|
||||
role: role === "custom" ? customRoleSlug : role,
|
||||
...(isTemporary
|
||||
? {
|
||||
isTemporary,
|
||||
temporaryMode,
|
||||
temporaryRange,
|
||||
temporaryAccessStartTime,
|
||||
temporaryAccessEndTime
|
||||
}
|
||||
: {
|
||||
isTemporary
|
||||
})
|
||||
})
|
||||
),
|
||||
membershipId: membershipDetails.id
|
||||
});
|
||||
createNotification({ type: "success", text: "Successfully removed role" });
|
||||
handlePopUpClose("deleteRole");
|
||||
};
|
||||
|
||||
return (
|
||||
|
||||
+6
-10
@@ -126,16 +126,12 @@ export const MemberRoleModify = ({ projectMember, onOpenUpgradeModal }: Props) =
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await updateMembershipRole.mutateAsync({
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
} catch {
|
||||
createNotification({ text: "Failed to update roles", type: "error" });
|
||||
}
|
||||
await updateMembershipRole.mutateAsync({
|
||||
projectId,
|
||||
membershipId: projectMember.id,
|
||||
roles: sanitizedRoles
|
||||
});
|
||||
createNotification({ text: "Successfully updated roles", type: "success" });
|
||||
};
|
||||
|
||||
if (isRolesLoading)
|
||||
|
||||
Reference in New Issue
Block a user