mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-04 10:26:16 +00:00
improvements: minor refactoring
This commit is contained in:
@@ -24,5 +24,7 @@ export const formatProjectRoleName = (name: string) => {
|
|||||||
export const isCustomProjectRole = (slug: string) =>
|
export const isCustomProjectRole = (slug: string) =>
|
||||||
!Object.values(ProjectMembershipRole).includes(slug as ProjectMembershipRole);
|
!Object.values(ProjectMembershipRole).includes(slug as ProjectMembershipRole);
|
||||||
|
|
||||||
export const findOrgMembershipRole = (roles: TOrgRole[], role: string) =>
|
export const findOrgMembershipRole = (roles: TOrgRole[], roleIdOrSlug: string) =>
|
||||||
isCustomOrgRole(role) ? roles.find((r) => r.id === role) : roles.find((r) => r.slug === role);
|
isCustomOrgRole(roleIdOrSlug)
|
||||||
|
? roles.find((r) => r.id === roleIdOrSlug)
|
||||||
|
: roles.find((r) => r.slug === roleIdOrSlug);
|
||||||
|
|||||||
+5
-4
@@ -15,7 +15,7 @@ import {
|
|||||||
TextArea
|
TextArea
|
||||||
} from "@app/components/v2";
|
} from "@app/components/v2";
|
||||||
import { useOrganization } from "@app/context";
|
import { useOrganization } from "@app/context";
|
||||||
import { isCustomOrgRole } from "@app/helpers/roles";
|
import { findOrgMembershipRole } from "@app/helpers/roles";
|
||||||
import {
|
import {
|
||||||
useAddUsersToOrg,
|
useAddUsersToOrg,
|
||||||
useFetchServerStatus,
|
useFetchServerStatus,
|
||||||
@@ -87,9 +87,10 @@ export const AddOrgMemberModal = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (organizationRoles) {
|
if (organizationRoles) {
|
||||||
reset({
|
reset({
|
||||||
organizationRole: isCustomOrgRole(currentOrg?.defaultMembershipRole!)
|
organizationRole: findOrgMembershipRole(
|
||||||
? organizationRoles?.find((role) => role.id === currentOrg?.defaultMembershipRole)
|
organizationRoles,
|
||||||
: organizationRoles?.find((role) => role.slug === currentOrg?.defaultMembershipRole)
|
currentOrg?.defaultMembershipRole!
|
||||||
|
)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [organizationRoles]);
|
}, [organizationRoles]);
|
||||||
|
|||||||
Reference in New Issue
Block a user