mirror of
https://github.com/logto-io/logto.git
synced 2025-01-06 20:40:08 -05:00
refactor(console): update jit styles
This commit is contained in:
parent
128ee0c9bb
commit
847a7c413a
3 changed files with 59 additions and 81 deletions
|
@ -2,19 +2,16 @@
|
||||||
|
|
||||||
.jitContent {
|
.jitContent {
|
||||||
margin-top: _.unit(3);
|
margin-top: _.unit(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
.membershipDescription {
|
||||||
|
font: var(--font-body-2);
|
||||||
|
color: var(--color-text-secondary);
|
||||||
|
margin-top: _.unit(1.5);
|
||||||
|
}
|
||||||
|
|
||||||
.description {
|
.emailDomains {
|
||||||
font: var(--font-body-2);
|
margin-top: _.unit(1);
|
||||||
color: var(--color-text-secondary);
|
|
||||||
margin-top: _.unit(1.5);
|
|
||||||
margin-left: _.unit(6.5);
|
|
||||||
}
|
|
||||||
|
|
||||||
.emailDomains {
|
|
||||||
margin-top: _.unit(1);
|
|
||||||
margin-left: _.unit(6);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.warning {
|
.warning {
|
||||||
|
|
|
@ -14,7 +14,6 @@ import { isDevFeaturesEnabled } from '@/consts/env';
|
||||||
import CodeEditor from '@/ds-components/CodeEditor';
|
import CodeEditor from '@/ds-components/CodeEditor';
|
||||||
import FormField from '@/ds-components/FormField';
|
import FormField from '@/ds-components/FormField';
|
||||||
import InlineNotification from '@/ds-components/InlineNotification';
|
import InlineNotification from '@/ds-components/InlineNotification';
|
||||||
import RadioGroup, { Radio } from '@/ds-components/RadioGroup';
|
|
||||||
import Switch from '@/ds-components/Switch';
|
import Switch from '@/ds-components/Switch';
|
||||||
import TextInput from '@/ds-components/TextInput';
|
import TextInput from '@/ds-components/TextInput';
|
||||||
import useApi, { type RequestError } from '@/hooks/use-api';
|
import useApi, { type RequestError } from '@/hooks/use-api';
|
||||||
|
@ -66,13 +65,14 @@ function Settings() {
|
||||||
formState: { isDirty, isSubmitting, errors },
|
formState: { isDirty, isSubmitting, errors },
|
||||||
setError,
|
setError,
|
||||||
clearErrors,
|
clearErrors,
|
||||||
getValues,
|
watch,
|
||||||
} = useForm<FormData>({
|
} = useForm<FormData>({
|
||||||
defaultValues: normalizeData(
|
defaultValues: normalizeData(
|
||||||
data,
|
data,
|
||||||
emailDomains.map(({ emailDomain }) => emailDomain)
|
emailDomains.map(({ emailDomain }) => emailDomain)
|
||||||
),
|
),
|
||||||
});
|
});
|
||||||
|
const [isJitEnabled, isMfaRequired] = watch(['isJitEnabled', 'isMfaRequired']);
|
||||||
const api = useApi();
|
const api = useApi();
|
||||||
|
|
||||||
const onSubmit = handleSubmit(
|
const onSubmit = handleSubmit(
|
||||||
|
@ -144,76 +144,58 @@ function Settings() {
|
||||||
description="organization_details.membership_policies_description"
|
description="organization_details.membership_policies_description"
|
||||||
>
|
>
|
||||||
<FormField title="organization_details.jit.is_enabled_title">
|
<FormField title="organization_details.jit.is_enabled_title">
|
||||||
<Controller
|
<div className={styles.jitContent}>
|
||||||
name="isJitEnabled"
|
<Switch
|
||||||
control={control}
|
label={t('organization_details.jit.description')}
|
||||||
render={({ field }) => (
|
{...register('isJitEnabled')}
|
||||||
<div className={styles.jitContent}>
|
/>
|
||||||
<RadioGroup
|
</div>
|
||||||
name="isJitEnabled"
|
|
||||||
value={String(field.value)}
|
|
||||||
onChange={(value) => {
|
|
||||||
field.onChange(value === 'true');
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Radio
|
|
||||||
value="false"
|
|
||||||
title="organization_details.jit.is_enabled_false_description"
|
|
||||||
/>
|
|
||||||
<Radio
|
|
||||||
value="true"
|
|
||||||
title="organization_details.jit.is_enabled_true_description"
|
|
||||||
/>
|
|
||||||
</RadioGroup>
|
|
||||||
{field.value && (
|
|
||||||
<>
|
|
||||||
<p className={styles.description}>
|
|
||||||
{t('organization_details.jit.description')}
|
|
||||||
</p>
|
|
||||||
<Controller
|
|
||||||
name="jitEmailDomains"
|
|
||||||
control={control}
|
|
||||||
render={({ field: { onChange, value } }) => (
|
|
||||||
<MultiOptionInput
|
|
||||||
className={styles.emailDomains}
|
|
||||||
values={value}
|
|
||||||
renderValue={(value) => value}
|
|
||||||
validateInput={(input) => {
|
|
||||||
if (!domainRegExp.test(input)) {
|
|
||||||
return t('organization_details.jit.invalid_domain');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (value.includes(input)) {
|
|
||||||
return t('organization_details.jit.domain_already_added');
|
|
||||||
}
|
|
||||||
|
|
||||||
return { value: input };
|
|
||||||
}}
|
|
||||||
placeholder={t('organization_details.jit.email_domains_placeholder')}
|
|
||||||
error={errors.jitEmailDomains?.message}
|
|
||||||
onChange={onChange}
|
|
||||||
onError={(error) => {
|
|
||||||
setError('jitEmailDomains', { type: 'custom', message: error });
|
|
||||||
}}
|
|
||||||
onClearError={() => {
|
|
||||||
clearErrors('jitEmailDomains');
|
|
||||||
}}
|
|
||||||
/>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</div>
|
|
||||||
)}
|
|
||||||
/>
|
|
||||||
</FormField>
|
</FormField>
|
||||||
|
{isJitEnabled && (
|
||||||
|
<FormField title="organization_details.jit.email_domain_provisioning">
|
||||||
|
<p className={styles.membershipDescription}>
|
||||||
|
{t('organization_details.jit.membership_description')}
|
||||||
|
</p>
|
||||||
|
<Controller
|
||||||
|
name="jitEmailDomains"
|
||||||
|
control={control}
|
||||||
|
render={({ field: { onChange, value } }) => (
|
||||||
|
<MultiOptionInput
|
||||||
|
className={styles.emailDomains}
|
||||||
|
values={value}
|
||||||
|
renderValue={(value) => value}
|
||||||
|
validateInput={(input) => {
|
||||||
|
if (!domainRegExp.test(input)) {
|
||||||
|
return t('organization_details.jit.invalid_domain');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (value.includes(input)) {
|
||||||
|
return t('organization_details.jit.domain_already_added');
|
||||||
|
}
|
||||||
|
|
||||||
|
return { value: input };
|
||||||
|
}}
|
||||||
|
placeholder={t('organization_details.jit.email_domains_placeholder')}
|
||||||
|
error={errors.jitEmailDomains?.message}
|
||||||
|
onChange={onChange}
|
||||||
|
onError={(error) => {
|
||||||
|
setError('jitEmailDomains', { type: 'custom', message: error });
|
||||||
|
}}
|
||||||
|
onClearError={() => {
|
||||||
|
clearErrors('jitEmailDomains');
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
|
</FormField>
|
||||||
|
)}
|
||||||
{isDevFeaturesEnabled && (
|
{isDevFeaturesEnabled && (
|
||||||
<FormField title="organization_details.mfa.title" tip={t('organization_details.mfa.tip')}>
|
<FormField title="organization_details.mfa.title" tip={t('organization_details.mfa.tip')}>
|
||||||
<Switch
|
<Switch
|
||||||
label={t('organization_details.mfa.description')}
|
label={t('organization_details.mfa.description')}
|
||||||
{...register('isMfaRequired')}
|
{...register('isMfaRequired')}
|
||||||
/>
|
/>
|
||||||
{getValues('isMfaRequired') && signInExperience?.mfa.factors.length === 0 && (
|
{isMfaRequired && signInExperience?.mfa.factors.length === 0 && (
|
||||||
<InlineNotification severity="alert" className={styles.warning}>
|
<InlineNotification severity="alert" className={styles.warning}>
|
||||||
{t('organization_details.mfa.no_mfa_warning')}
|
{t('organization_details.mfa.no_mfa_warning')}
|
||||||
</InlineNotification>
|
</InlineNotification>
|
||||||
|
|
|
@ -31,12 +31,11 @@ const organization_details = {
|
||||||
'Define how users can join this organization and what requirements they must meet for access.',
|
'Define how users can join this organization and what requirements they must meet for access.',
|
||||||
jit: {
|
jit: {
|
||||||
description:
|
description:
|
||||||
'Automatically assign users into this organization when they sign up or are added through the Management API, provided their email addresses match the specified domains.',
|
'Enable automatic membership assignment based on verified email domains and default roles assignment.',
|
||||||
|
membership_description:
|
||||||
|
'Automatically assign users into this organization when they sign up or are added through the Management API, provided their verified email addresses match the specified domains.',
|
||||||
is_enabled_title: 'Enable just-in-time provisioning',
|
is_enabled_title: 'Enable just-in-time provisioning',
|
||||||
is_enabled_true_description:
|
email_domain_provisioning: 'Email domain provisioning',
|
||||||
'New users with verified email domains will automatically join the organization',
|
|
||||||
is_enabled_false_description:
|
|
||||||
'Users can join the organization only if they are invited or added via Management API',
|
|
||||||
email_domains_placeholder: 'Enter email domains for just-in-time provisioning',
|
email_domains_placeholder: 'Enter email domains for just-in-time provisioning',
|
||||||
invalid_domain: 'Invalid domain',
|
invalid_domain: 'Invalid domain',
|
||||||
domain_already_added: 'Domain already added',
|
domain_already_added: 'Domain already added',
|
||||||
|
|
Loading…
Reference in a new issue