mirror of
https://github.com/awatertrevi/infisical.git
synced 2026-10-05 10:26:35 +00:00
improvement: filter select for invite users to org
This commit is contained in:
@@ -33,7 +33,7 @@ export const getDefaultOnPremFeatures = (): TFeatureSet => ({
|
|||||||
oidcSSO: false,
|
oidcSSO: false,
|
||||||
scim: false,
|
scim: false,
|
||||||
ldap: false,
|
ldap: false,
|
||||||
groups: true,
|
groups: false,
|
||||||
status: null,
|
status: null,
|
||||||
trial_end: null,
|
trial_end: null,
|
||||||
has_used_trial: true,
|
has_used_trial: true,
|
||||||
|
|||||||
+16
-21
@@ -45,7 +45,7 @@ const addMemberFormSchema = z.object({
|
|||||||
)
|
)
|
||||||
.default([]),
|
.default([]),
|
||||||
projectRoleSlug: z.string().min(1).default(DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG),
|
projectRoleSlug: z.string().min(1).default(DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG),
|
||||||
organizationRoleSlug: z.string().min(1).default(DEFAULT_ORG_AND_PROJECT_MEMBER_ROLE_SLUG)
|
organizationRole: z.object({ name: z.string(), slug: z.string() })
|
||||||
});
|
});
|
||||||
|
|
||||||
type TAddMemberForm = z.infer<typeof addMemberFormSchema>;
|
type TAddMemberForm = z.infer<typeof addMemberFormSchema>;
|
||||||
@@ -87,16 +87,16 @@ export const AddOrgMemberModal = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (organizationRoles) {
|
if (organizationRoles) {
|
||||||
reset({
|
reset({
|
||||||
organizationRoleSlug: isCustomOrgRole(currentOrg?.defaultMembershipRole!)
|
organizationRole: isCustomOrgRole(currentOrg?.defaultMembershipRole!)
|
||||||
? organizationRoles?.find((role) => role.id === currentOrg?.defaultMembershipRole)?.slug!
|
? organizationRoles?.find((role) => role.id === currentOrg?.defaultMembershipRole)
|
||||||
: currentOrg?.defaultMembershipRole
|
: organizationRoles?.find((role) => role.slug === currentOrg?.defaultMembershipRole)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}, [organizationRoles]);
|
}, [organizationRoles]);
|
||||||
|
|
||||||
const onAddMembers = async ({
|
const onAddMembers = async ({
|
||||||
emails,
|
emails,
|
||||||
organizationRoleSlug,
|
organizationRole,
|
||||||
projects: selectedProjects,
|
projects: selectedProjects,
|
||||||
projectRoleSlug
|
projectRoleSlug
|
||||||
}: TAddMemberForm) => {
|
}: TAddMemberForm) => {
|
||||||
@@ -138,7 +138,7 @@ export const AddOrgMemberModal = ({
|
|||||||
const { data } = await addUsersMutateAsync({
|
const { data } = await addUsersMutateAsync({
|
||||||
organizationId: currentOrg?.id,
|
organizationId: currentOrg?.id,
|
||||||
inviteeEmails: emails.split(",").map((email) => email.trim()),
|
inviteeEmails: emails.split(",").map((email) => email.trim()),
|
||||||
organizationRoleSlug,
|
organizationRoleSlug: organizationRole.slug,
|
||||||
projects: selectedProjects.map(({ id }) => ({ id, projectRoleSlug: [projectRoleSlug] }))
|
projects: selectedProjects.map(({ id }) => ({ id, projectRoleSlug: [projectRoleSlug] }))
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -207,27 +207,22 @@ export const AddOrgMemberModal = ({
|
|||||||
|
|
||||||
<Controller
|
<Controller
|
||||||
control={control}
|
control={control}
|
||||||
name="organizationRoleSlug"
|
name="organizationRole"
|
||||||
render={({ field, fieldState: { error } }) => (
|
render={({ field: { value, onChange }, fieldState: { error } }) => (
|
||||||
<FormControl
|
<FormControl
|
||||||
tooltipText="Select which organization role you want to assign to the user."
|
tooltipText="Select which organization role you want to assign to the user."
|
||||||
label="Assign organization role"
|
label="Assign organization role"
|
||||||
isError={Boolean(error)}
|
isError={Boolean(error)}
|
||||||
errorText={error?.message}
|
errorText={error?.message}
|
||||||
>
|
>
|
||||||
<div>
|
<FilterableSelect
|
||||||
<Select
|
placeholder="Select role..."
|
||||||
className="w-full"
|
options={organizationRoles}
|
||||||
{...field}
|
getOptionValue={(option) => option.slug}
|
||||||
onValueChange={(val) => field.onChange(val)}
|
getOptionLabel={(option) => option.name}
|
||||||
>
|
value={value}
|
||||||
{organizationRoles?.map((role) => (
|
onChange={onChange}
|
||||||
<SelectItem key={role.id} value={role.slug}>
|
/>
|
||||||
{role.name}
|
|
||||||
</SelectItem>
|
|
||||||
))}
|
|
||||||
</Select>
|
|
||||||
</div>
|
|
||||||
</FormControl>
|
</FormControl>
|
||||||
)}
|
)}
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in New Issue
Block a user