2020-10-30 20:15:37 +00:00
|
|
|
import {
|
|
|
|
FormGroup,
|
|
|
|
Select,
|
|
|
|
SelectOption,
|
2020-11-25 14:50:40 +00:00
|
|
|
SelectVariant,
|
2020-10-30 20:15:37 +00:00
|
|
|
Switch,
|
|
|
|
TextInput,
|
|
|
|
} from "@patternfly/react-core";
|
|
|
|
import { useTranslation } from "react-i18next";
|
2021-01-26 01:41:14 +00:00
|
|
|
import React, { useState } from "react";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { HelpItem } from "../../components/help-enabler/HelpItem";
|
2021-01-26 01:41:14 +00:00
|
|
|
import { UseFormMethods, Controller } from "react-hook-form";
|
2020-12-16 07:02:41 +00:00
|
|
|
import { FormAccess } from "../../components/form-access/FormAccess";
|
2021-01-04 21:33:18 +00:00
|
|
|
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
|
2020-10-30 20:15:37 +00:00
|
|
|
|
2021-01-04 21:33:18 +00:00
|
|
|
export type LdapSettingsSearchingProps = {
|
2021-01-26 01:41:14 +00:00
|
|
|
form: UseFormMethods;
|
2021-01-04 21:33:18 +00:00
|
|
|
showSectionHeading?: boolean;
|
|
|
|
showSectionDescription?: boolean;
|
|
|
|
};
|
|
|
|
|
|
|
|
export const LdapSettingsSearching = ({
|
2021-01-26 01:41:14 +00:00
|
|
|
form,
|
2021-01-04 21:33:18 +00:00
|
|
|
showSectionHeading = false,
|
|
|
|
showSectionDescription = false,
|
|
|
|
}: LdapSettingsSearchingProps) => {
|
2020-10-30 20:15:37 +00:00
|
|
|
const { t } = useTranslation("user-federation");
|
|
|
|
const helpText = useTranslation("user-federation-help").t;
|
2021-01-26 01:41:14 +00:00
|
|
|
|
2021-07-05 11:24:10 +00:00
|
|
|
const [isSearchScopeDropdownOpen, setIsSearchScopeDropdownOpen] =
|
|
|
|
useState(false);
|
2021-01-26 01:41:14 +00:00
|
|
|
const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false);
|
2020-11-25 14:50:40 +00:00
|
|
|
|
2020-10-30 20:15:37 +00:00
|
|
|
return (
|
|
|
|
<>
|
2021-01-04 21:33:18 +00:00
|
|
|
{showSectionHeading && (
|
|
|
|
<WizardSectionHeader
|
|
|
|
title={t("ldapSearchingAndUpdatingSettings")}
|
|
|
|
description={helpText("ldapSearchingAndUpdatingSettingsDescription")}
|
|
|
|
showDescription={showSectionDescription}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
|
2020-11-25 16:17:50 +00:00
|
|
|
<FormAccess role="manage-realm" isHorizontal>
|
2020-10-30 20:15:37 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("editMode")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
2020-11-24 13:56:31 +00:00
|
|
|
helpText={helpText("editModeLdapHelp")}
|
2020-10-30 20:15:37 +00:00
|
|
|
forLabel={t("editMode")}
|
|
|
|
forID="kc-edit-mode"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-edit-mode"
|
2021-09-23 14:11:41 +00:00
|
|
|
isRequired
|
2020-10-30 20:15:37 +00:00
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.editMode[0]"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue=""
|
2021-01-26 01:41:14 +00:00
|
|
|
control={form.control}
|
2021-09-23 14:11:41 +00:00
|
|
|
rules={{
|
|
|
|
required: { value: true, message: t("validateEditMode") },
|
|
|
|
}}
|
2020-11-25 14:50:40 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
toggleId="kc-edit-mode"
|
|
|
|
required
|
|
|
|
onToggle={() =>
|
|
|
|
setIsEditModeDropdownOpen(!isEditModeDropdownOpen)
|
|
|
|
}
|
|
|
|
isOpen={isEditModeDropdownOpen}
|
|
|
|
onSelect={(_, value) => {
|
2021-09-23 14:11:41 +00:00
|
|
|
onChange(value.toString());
|
2020-11-25 14:50:40 +00:00
|
|
|
setIsEditModeDropdownOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value}
|
|
|
|
variant={SelectVariant.single}
|
|
|
|
>
|
2021-09-23 14:11:41 +00:00
|
|
|
<SelectOption value="" isPlaceholder />
|
|
|
|
<SelectOption value="READ_ONLY" />
|
|
|
|
<SelectOption value="WRITABLE" />
|
|
|
|
<SelectOption value="UNSYNCED" />
|
2020-11-25 14:50:40 +00:00
|
|
|
</Select>
|
|
|
|
)}
|
2021-09-23 14:11:41 +00:00
|
|
|
/>
|
|
|
|
{form.errors.config?.editMode?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.editMode[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("usersDN")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("usersDNHelp")}
|
|
|
|
forLabel={t("usersDN")}
|
|
|
|
forID="kc-console-users-dn"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-console-users-dn"
|
|
|
|
isRequired
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
2021-05-14 18:12:27 +00:00
|
|
|
defaultValue=""
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-console-users-dn"
|
2021-02-23 20:49:57 +00:00
|
|
|
data-testid="ldap-users-dn"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.usersDn[0]"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateUsersDn")}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.usersDn?.[0] && (
|
|
|
|
<div className="error">{form.errors.config.usersDn[0].message}</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("usernameLdapAttribute")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("usernameLdapAttributeHelp")}
|
|
|
|
forLabel={t("usernameLdapAttribute")}
|
|
|
|
forID="kc-username-ldap-attribute"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-username-ldap-attribute"
|
|
|
|
isRequired
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
2021-05-14 18:12:27 +00:00
|
|
|
defaultValue="cn"
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-username-ldap-attribute"
|
2021-02-23 20:49:57 +00:00
|
|
|
data-testid="ldap-username-attribute"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.usernameLDAPAttribute[0]"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateUsernameLDAPAttribute")}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.usernameLDAPAttribute?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.usernameLDAPAttribute[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("rdnLdapAttribute")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("rdnLdapAttributeHelp")}
|
|
|
|
forLabel={t("rdnLdapAttribute")}
|
|
|
|
forID="kc-rdn-ldap-attribute"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-rdn-ldap-attribute"
|
|
|
|
isRequired
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
2021-05-14 18:12:27 +00:00
|
|
|
defaultValue="cn"
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-rdn-ldap-attribute"
|
2021-02-23 20:49:57 +00:00
|
|
|
data-testid="ldap-rdn-attribute"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.rdnLDAPAttribute[0]"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateRdnLdapAttribute")}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.rdnLDAPAttribute?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.rdnLDAPAttribute[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("uuidLdapAttribute")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("uuidLdapAttributeHelp")}
|
|
|
|
forLabel={t("uuidLdapAttribute")}
|
|
|
|
forID="kc-uuid-ldap-attribute"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-uuid-ldap-attribute"
|
|
|
|
isRequired
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
2021-05-14 18:12:27 +00:00
|
|
|
defaultValue="objectGUID"
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-uuid-ldap-attribute"
|
2021-02-23 20:49:57 +00:00
|
|
|
data-testid="ldap-uuid-attribute"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.uuidLDAPAttribute[0]"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateUuidLDAPAttribute")}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.uuidLDAPAttribute?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.uuidLDAPAttribute[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("userObjectClasses")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("userObjectClassesHelp")}
|
|
|
|
forLabel={t("userObjectClasses")}
|
|
|
|
forID="kc-user-object-classes"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-user-object-classes"
|
|
|
|
isRequired
|
|
|
|
>
|
|
|
|
<TextInput
|
|
|
|
isRequired
|
|
|
|
type="text"
|
2021-05-14 18:12:27 +00:00
|
|
|
defaultValue="person, organizationalPerson, user"
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-user-object-classes"
|
2021-02-23 20:49:57 +00:00
|
|
|
data-testid="ldap-user-object-classes"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.userObjectClasses[0]"
|
|
|
|
ref={form.register({
|
|
|
|
required: {
|
|
|
|
value: true,
|
|
|
|
message: `${t("validateUserObjectClasses")}`,
|
|
|
|
},
|
|
|
|
})}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.userObjectClasses?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.userObjectClasses[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("userLdapFilter")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("userLdapFilterHelp")}
|
|
|
|
forLabel={t("userLdapFilter")}
|
|
|
|
forID="kc-user-ldap-filter"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-user-ldap-filter"
|
|
|
|
>
|
2020-12-16 07:02:41 +00:00
|
|
|
<TextInput
|
|
|
|
type="text"
|
|
|
|
id="kc-user-ldap-filter"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.customUserSearchFilter[0]"
|
2021-02-23 20:49:57 +00:00
|
|
|
ref={form.register({
|
2021-02-22 19:48:03 +00:00
|
|
|
pattern: {
|
|
|
|
value: /(\(.*\))$/,
|
2021-02-23 20:49:57 +00:00
|
|
|
message: `${t("validateCustomUserSearchFilter")}`,
|
|
|
|
},
|
2021-02-22 19:48:03 +00:00
|
|
|
})}
|
2020-12-16 07:02:41 +00:00
|
|
|
/>
|
2021-08-12 11:15:47 +00:00
|
|
|
{form.errors.config?.customUserSearchFilter?.[0] && (
|
|
|
|
<div className="error">
|
|
|
|
{form.errors.config.customUserSearchFilter[0].message}
|
|
|
|
</div>
|
|
|
|
)}
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
2021-01-26 01:41:14 +00:00
|
|
|
|
2020-10-30 20:15:37 +00:00
|
|
|
<FormGroup
|
|
|
|
label={t("searchScope")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("searchScopeHelp")}
|
|
|
|
forLabel={t("searchScope")}
|
|
|
|
forID="kc-search-scope"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-search-scope"
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.searchScope[0]"
|
2020-11-25 14:50:40 +00:00
|
|
|
defaultValue=""
|
2021-01-26 01:41:14 +00:00
|
|
|
control={form.control}
|
2020-11-25 14:50:40 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Select
|
|
|
|
toggleId="kc-search-scope"
|
|
|
|
required
|
|
|
|
onToggle={() =>
|
|
|
|
setIsSearchScopeDropdownOpen(!isSearchScopeDropdownOpen)
|
|
|
|
}
|
|
|
|
isOpen={isSearchScopeDropdownOpen}
|
|
|
|
onSelect={(_, value) => {
|
|
|
|
onChange(value as string);
|
|
|
|
setIsSearchScopeDropdownOpen(false);
|
|
|
|
}}
|
|
|
|
selections={value}
|
|
|
|
variant={SelectVariant.single}
|
|
|
|
>
|
2021-01-26 01:41:14 +00:00
|
|
|
<SelectOption key={0} value="1" isPlaceholder>
|
|
|
|
{t("oneLevel")}
|
|
|
|
</SelectOption>
|
|
|
|
<SelectOption key={1} value="2">
|
|
|
|
{t("subtree")}
|
|
|
|
</SelectOption>
|
2020-11-25 14:50:40 +00:00
|
|
|
</Select>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("readTimeout")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("readTimeoutHelp")}
|
|
|
|
forLabel={t("readTimeout")}
|
|
|
|
forID="kc-read-timeout"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-read-timeout"
|
|
|
|
>
|
|
|
|
<TextInput
|
2021-02-22 19:48:03 +00:00
|
|
|
type="number"
|
2021-03-02 15:37:51 +00:00
|
|
|
min={0}
|
2020-10-30 20:15:37 +00:00
|
|
|
id="kc-read-timeout"
|
2021-01-26 01:41:14 +00:00
|
|
|
name="config.readTimeout[0]"
|
|
|
|
ref={form.register}
|
2020-10-30 20:15:37 +00:00
|
|
|
/>
|
|
|
|
</FormGroup>
|
|
|
|
<FormGroup
|
|
|
|
label={t("pagination")}
|
|
|
|
labelIcon={
|
|
|
|
<HelpItem
|
|
|
|
helpText={helpText("paginationHelp")}
|
|
|
|
forLabel={t("pagination")}
|
|
|
|
forID="kc-console-pagination"
|
|
|
|
/>
|
|
|
|
}
|
|
|
|
fieldId="kc-console-pagination"
|
|
|
|
hasNoPaddingTop
|
|
|
|
>
|
2020-11-25 14:50:40 +00:00
|
|
|
<Controller
|
2020-12-16 07:02:41 +00:00
|
|
|
name="config.pagination"
|
2021-02-19 23:13:07 +00:00
|
|
|
defaultValue={["false"]}
|
2021-01-26 01:41:14 +00:00
|
|
|
control={form.control}
|
2020-11-25 14:50:40 +00:00
|
|
|
render={({ onChange, value }) => (
|
|
|
|
<Switch
|
|
|
|
id={"kc-console-pagination"}
|
|
|
|
isDisabled={false}
|
2021-01-26 01:41:14 +00:00
|
|
|
onChange={(value) => onChange([`${value}`])}
|
|
|
|
isChecked={value[0] === "true"}
|
2020-11-25 14:50:40 +00:00
|
|
|
label={t("common:on")}
|
|
|
|
labelOff={t("common:off")}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
></Controller>
|
2020-10-30 20:15:37 +00:00
|
|
|
</FormGroup>
|
2020-11-25 16:17:50 +00:00
|
|
|
</FormAccess>
|
2020-10-30 20:15:37 +00:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|