import { Button, FormGroup, InputGroup, 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 { Controller, useForm } from "react-hook-form"; import { convertToFormValues } from "../../util"; import ComponentRepresentation from "keycloak-admin/lib/defs/componentRepresentation"; import { EyeIcon } from "@patternfly/react-icons"; import { FormAccess } from "../../components/form-access/FormAccess"; import { useAdminClient } from "../../context/auth/AdminClient"; import { useParams } from "react-router-dom"; export const LdapSettingsConnection = () => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const adminClient = useAdminClient(); const { register, control, setValue } = useForm(); const { id } = useParams<{ id: string }>(); const convertTruststoreSpiValues = (truststoreValue: string) => { switch (truststoreValue) { case "always": return `${t("always")}`; case "never": return `${t("never")}`; case "ldapsOnly": default: return `${t("onlyLdaps")}`; } }; const [ isTruststoreSpiDropdownOpen, setIsTruststoreSpiDropdownOpen, ] = useState(false); const [isBindTypeDropdownOpen, setIsBindTypeDropdownOpen] = useState(false); const setupForm = (component: ComponentRepresentation) => { Object.entries(component).map((entry) => { if (entry[0] === "config") { convertToFormValues(entry[1], "config", setValue); if (entry[1].useTruststoreSpi) { setValue( "config.useTruststoreSpi", convertTruststoreSpiValues(entry[1].useTruststoreSpi[0]) ); } } else { setValue(entry[0], entry[1]); } }); }; useEffect(() => { (async () => { const fetchedComponent = await adminClient.components.findOne({ id }); if (fetchedComponent) { setupForm(fetchedComponent); } })(); }, []); return ( <> } fieldId="kc-console-connection-url" isRequired > } fieldId="kc-enable-start-tls" hasNoPaddingTop > ( )} > } fieldId="kc-use-truststore-spi" > ( )} > } fieldId="kc-connection-pooling" hasNoPaddingTop > ( )} > } fieldId="kc-console-connection-timeout" > } fieldId="kc-bind-type" isRequired > ( )} > } fieldId="kc-console-bind-dn" > } fieldId="kc-console-bind-credentials" isRequired > {/* TODO: MF The input group below throws a 'React does not recognize the `isDisabled` prop on a DOM element' error */} {" "} {/* TODO: whatever this button is supposed to do */} ); };