import { Button, FormGroup, Select, SelectOption, SelectVariant, Switch, TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import React, { useState } from "react"; import _ from "lodash"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { Controller, UseFormMethods, useWatch } from "react-hook-form"; import { FormAccess } from "../../components/form-access/FormAccess"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; import { PasswordInput } from "../../components/password-input/PasswordInput"; export type LdapSettingsConnectionProps = { form: UseFormMethods; showSectionHeading?: boolean; showSectionDescription?: boolean; }; export const LdapSettingsConnection = ({ form, showSectionHeading = false, showSectionDescription = false, }: LdapSettingsConnectionProps) => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const [ isTruststoreSpiDropdownOpen, setIsTruststoreSpiDropdownOpen, ] = useState(false); const [isBindTypeDropdownOpen, setIsBindTypeDropdownOpen] = useState(false); const ldapBindType = useWatch({ control: form.control, name: "config.authType", }); return ( <> {showSectionHeading && ( )} } fieldId="kc-console-connection-url" isRequired > {form.errors.config && form.errors.config.connectionUrl && form.errors.config.connectionUrl[0] && (
{form.errors.config.connectionUrl[0].message}
)}
} fieldId="kc-enable-start-tls" hasNoPaddingTop > ( onChange([`${value}`])} isChecked={value[0] === "true"} label={t("common:on")} labelOff={t("common:off")} /> )} > } fieldId="kc-use-truststore-spi" > ( )} > } fieldId="kc-connection-pooling" hasNoPaddingTop > ( onChange([`${value}`])} isChecked={value[0] === "true"} label={t("common:on")} labelOff={t("common:off")} /> )} > } fieldId="kc-console-connection-timeout" > } fieldId="kc-bind-type" isRequired > ( )} > {_.isEqual(ldapBindType, ["simple"]) ? ( <> } fieldId="kc-console-bind-dn" isRequired > {form.errors.config && form.errors.config.bindDn && form.errors.config.bindDn[0] && (
{form.errors.config.bindDn[0].message}
)}
} fieldId="kc-console-bind-credentials" isRequired > {form.errors.config && form.errors.config.bindCredential && form.errors.config.bindCredential[0] && (
{form.errors.config.bindCredential[0].message}
)}
{" "} {/* TODO: whatever this button is supposed to do */} ) : ( <> )}
); };