import { FormGroup, Select, SelectOption, SelectVariant, Switch, TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import React, { useEffect, useState } from "react"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { useForm, Controller } from "react-hook-form"; import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; import { FormAccess } from "../../components/form-access/FormAccess"; import { useAdminClient, asyncStateFetch, } from "../../context/auth/AdminClient"; import { useParams } from "react-router-dom"; import { convertToFormValues } from "../../util"; export const LdapSettingsSearching = () => { const { t } = useTranslation("user-federation"); const adminClient = useAdminClient(); const helpText = useTranslation("user-federation-help").t; const [isEditModeDropdownOpen, setIsEditModeDropdownOpen] = useState(false); const { id } = useParams<{ id: string }>(); const [isSearchScopeDropdownOpen, setIsSearchScopeDropdownOpen] = useState( false ); const { register, control, setValue } = useForm(); const convertSearchScopes = (scope: string) => { switch (scope) { case "1": default: return `${t("oneLevel")}`; case "2": return `${t("subtree")}`; } }; const setupForm = (component: ComponentRepresentation) => { Object.entries(component).map((entry) => { if (entry[0] === "config") { convertToFormValues(entry[1], "config", setValue); if (entry[1].searchScope) { setValue( "config.searchScope", convertSearchScopes(entry[1].searchScope[0]) ); } } else { setValue(entry[0], entry[1]); } }); }; useEffect(() => { return asyncStateFetch( () => adminClient.components.findOne({ id }), (fetchedComponent) => setupForm(fetchedComponent) ); }, []); return ( <> } fieldId="kc-edit-mode" > ( )} > } fieldId="kc-console-users-dn" isRequired > } fieldId="kc-username-ldap-attribute" isRequired > } fieldId="kc-rdn-ldap-attribute" isRequired > } fieldId="kc-uuid-ldap-attribute" isRequired > } fieldId="kc-user-object-classes" isRequired > } fieldId="kc-user-ldap-filter" > } fieldId="kc-search-scope" > ( )} > } fieldId="kc-read-timeout" > } fieldId="kc-console-pagination" hasNoPaddingTop > ( )} > ); };