|
|
@@ -6,8 +6,8 @@ import { useTranslation } from 'react-i18next';
|
|
|
|
|
|
import { apiv3Put } from '~/client/util/apiv3-client';
|
|
|
import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
-import { LdapGroupSyncSettings } from '~/interfaces/external-user-group';
|
|
|
-import { useSWRxLdapGroupSyncSettings } from '~/stores/external-user-group';
|
|
|
+import { useSWRxLdapGroupSyncSettings } from '~/features/external-user-group/client/stores/external-user-group';
|
|
|
+import { LdapGroupMembershipAttributeType, LdapGroupSyncSettings } from '~/features/external-user-group/interfaces/external-user-group';
|
|
|
|
|
|
export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
const { t } = useTranslation('admin');
|
|
|
@@ -17,7 +17,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
const [formValues, setFormValues] = useState<LdapGroupSyncSettings>({
|
|
|
ldapGroupSearchBase: '',
|
|
|
ldapGroupMembershipAttribute: '',
|
|
|
- ldapGroupMembershipAttributeType: '',
|
|
|
+ ldapGroupMembershipAttributeType: LdapGroupMembershipAttributeType.dn,
|
|
|
ldapGroupChildGroupAttribute: '',
|
|
|
autoGenerateUserOnLdapGroupSync: false,
|
|
|
preserveDeletedLdapGroups: false,
|
|
|
@@ -35,18 +35,22 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
e.preventDefault();
|
|
|
try {
|
|
|
await apiv3Put('/external-user-groups/ldap/sync-settings', formValues);
|
|
|
- toastSuccess(t('external_group.ldap.updated_group_sync_settings'));
|
|
|
+ toastSuccess(t('external_user_group.ldap.updated_group_sync_settings'));
|
|
|
}
|
|
|
- catch (err) {
|
|
|
- toastError(err);
|
|
|
+ catch (errs) {
|
|
|
+ toastError(t(errs[0]?.message));
|
|
|
}
|
|
|
}, [formValues, t]);
|
|
|
|
|
|
return <>
|
|
|
- <h3 className="border-bottom mb-3">{t('external_group.ldap.group_sync_settings')}</h3>
|
|
|
+ <h3 className="border-bottom mb-3">{t('external_user_group.ldap.group_sync_settings')}</h3>
|
|
|
<form onSubmit={submitHandler}>
|
|
|
<div className="row form-group">
|
|
|
- <label htmlFor="ldapGroupSearchBase" className="text-left text-md-right col-md-3 col-form-label">{t('external_group.ldap.group_search_base_DN')}</label>
|
|
|
+ <label
|
|
|
+ htmlFor="ldapGroupSearchBase"
|
|
|
+ className="text-left text-md-right col-md-3 col-form-label">
|
|
|
+ {t('external_user_group.ldap.group_search_base_DN')}
|
|
|
+ </label>
|
|
|
<div className="col-md-6">
|
|
|
<input
|
|
|
className="form-control"
|
|
|
@@ -57,13 +61,13 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
onChange={e => setFormValues({ ...formValues, ldapGroupSearchBase: e.target.value })}
|
|
|
/>
|
|
|
<p className="form-text text-muted">
|
|
|
- <small>{t('external_group.ldap.group_search_base_dn_detail')}</small>
|
|
|
+ <small>{t('external_user_group.ldap.group_search_base_dn_detail')}</small>
|
|
|
</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="row form-group">
|
|
|
<label htmlFor="ldapGroupMembershipAttribute" className="text-left text-md-right col-md-3 col-form-label">
|
|
|
- {t('external_group.ldap.membership_attribute')}
|
|
|
+ {t('external_user_group.ldap.membership_attribute')}
|
|
|
</label>
|
|
|
<div className="col-md-6">
|
|
|
<input
|
|
|
@@ -77,15 +81,15 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
/>
|
|
|
<p className="form-text text-muted">
|
|
|
<small>
|
|
|
- {t('external_group.ldap.membership_attribute_detail')} <br />
|
|
|
- e.g.) <code>member</code>, <code>memberUid</code>
|
|
|
+ {t('external_user_group.ldap.membership_attribute_detail')} <br />
|
|
|
+ e.g.) <code>member</code>, <code>memberUid</code>
|
|
|
</small>
|
|
|
</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="row form-group">
|
|
|
<label htmlFor="ldapGroupMembershipAttributeType" className="text-left text-md-right col-md-3 col-form-label">
|
|
|
- {t('external_group.ldap.membership_attribute_type')}
|
|
|
+ {t('external_user_group.ldap.membership_attribute_type')}
|
|
|
</label>
|
|
|
<div className="col-md-6">
|
|
|
<select
|
|
|
@@ -94,20 +98,24 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
name="ldapGroupMembershipAttributeType"
|
|
|
id="ldapGroupMembershipAttributeType"
|
|
|
value={formValues.ldapGroupMembershipAttributeType}
|
|
|
- onChange={e => setFormValues({ ...formValues, ldapGroupMembershipAttributeType: e.target.value })}>
|
|
|
+ onChange={(e) => {
|
|
|
+ if (e.target.value === LdapGroupMembershipAttributeType.dn || e.target.value === LdapGroupMembershipAttributeType.uid) {
|
|
|
+ setFormValues({ ...formValues, ldapGroupMembershipAttributeType: e.target.value });
|
|
|
+ }
|
|
|
+ }}>
|
|
|
<option value="DN">DN</option>
|
|
|
<option value="UID">UID</option>
|
|
|
</select>
|
|
|
<p className="form-text text-muted">
|
|
|
<small>
|
|
|
- {t('external_group.ldap.membership_attribute_type_detail')}
|
|
|
+ {t('external_user_group.ldap.membership_attribute_type_detail')}
|
|
|
</small>
|
|
|
</p>
|
|
|
</div>
|
|
|
</div>
|
|
|
<div className="row form-group">
|
|
|
<label htmlFor="ldapGroupChildGroupAttribute" className="text-left text-md-right col-md-3 col-form-label">
|
|
|
- {t('external_group.ldap.child_group_attribute')}
|
|
|
+ {t('external_user_group.ldap.child_group_attribute')}
|
|
|
</label>
|
|
|
<div className="col-md-6">
|
|
|
<input
|
|
|
@@ -120,7 +128,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
onChange={e => setFormValues({ ...formValues, ldapGroupChildGroupAttribute: e.target.value })}/>
|
|
|
<p className="form-text text-muted">
|
|
|
<small>
|
|
|
- {t('external_group.ldap.child_group_attribute_detail')}<br />
|
|
|
+ {t('external_user_group.ldap.child_group_attribute_detail')}<br />
|
|
|
e.g.) <code>member</code>
|
|
|
</small>
|
|
|
</p>
|
|
|
@@ -130,7 +138,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
<label
|
|
|
className="text-left text-md-right col-md-3 col-form-label"
|
|
|
>
|
|
|
- {/* {t('external_group.ldap.auto_generate_user_on_sync')} */}
|
|
|
+ {/* {t('external_user_group.ldap.auto_generate_user_on_sync')} */}
|
|
|
</label>
|
|
|
<div className="col-md-6">
|
|
|
<div className="custom-control custom-checkbox custom-checkbox-info">
|
|
|
@@ -146,7 +154,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
className="custom-control-label"
|
|
|
htmlFor="autoGenerateUserOnLdapGroupSync"
|
|
|
>
|
|
|
- {t('external_group.ldap.auto_generate_user_on_sync')}
|
|
|
+ {t('external_user_group.ldap.auto_generate_user_on_sync')}
|
|
|
</label>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -155,7 +163,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
<label
|
|
|
className="text-left text-md-right col-md-3 col-form-label"
|
|
|
>
|
|
|
- {/* {t('external_group.ldap.preserve_deleted_ldap_groups')} */}
|
|
|
+ {/* {t('external_user_group.ldap.preserve_deleted_ldap_groups')} */}
|
|
|
</label>
|
|
|
<div className="col-md-6">
|
|
|
<div className="custom-control custom-checkbox custom-checkbox-info">
|
|
|
@@ -171,7 +179,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
className="custom-control-label"
|
|
|
htmlFor="preserveDeletedLdapGroups"
|
|
|
>
|
|
|
- {t('external_group.ldap.preserve_deleted_ldap_groups')}
|
|
|
+ {t('external_user_group.ldap.preserve_deleted_ldap_groups')}
|
|
|
</label>
|
|
|
</div>
|
|
|
</div>
|
|
|
@@ -193,7 +201,7 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
/>
|
|
|
<p className="form-text text-muted">
|
|
|
<small>
|
|
|
- {t('external_group.ldap.name_mapper_detail')}
|
|
|
+ {t('external_user_group.ldap.name_mapper_detail')}
|
|
|
</small>
|
|
|
</p>
|
|
|
</div>
|
|
|
@@ -208,12 +216,12 @@ export const LdapGroupSyncSettingsForm: FC = () => {
|
|
|
type="text"
|
|
|
name="ldapGroupDescriptionAttribute"
|
|
|
id="ldapGroupDescriptionAttribute"
|
|
|
- value={formValues.ldapGroupDescriptionAttribute}
|
|
|
+ value={formValues.ldapGroupDescriptionAttribute || ''}
|
|
|
onChange={e => setFormValues({ ...formValues, ldapGroupDescriptionAttribute: e.target.value })}
|
|
|
/>
|
|
|
<p className="form-text text-muted">
|
|
|
<small>
|
|
|
- {t('external_group.ldap.description_mapper_detail')}
|
|
|
+ {t('external_user_group.ldap.description_mapper_detail')}
|
|
|
</small>
|
|
|
</p>
|
|
|
</div>
|