keycloak-scim/src/user-federation/ldap/LdapSettingsAdvanced.tsx

121 lines
3.8 KiB
TypeScript
Raw Normal View History

2020-11-25 16:17:50 +00:00
import { FormGroup, Switch } from "@patternfly/react-core";
import { useTranslation } from "react-i18next";
import React from "react";
import { HelpItem } from "../../components/help-enabler/HelpItem";
import { UseFormMethods, Controller } from "react-hook-form";
import { FormAccess } from "../../components/form-access/FormAccess";
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
export type LdapSettingsAdvancedProps = {
form: UseFormMethods;
showSectionHeading?: boolean;
showSectionDescription?: boolean;
};
export const LdapSettingsAdvanced = ({
form,
showSectionHeading = false,
showSectionDescription = false,
}: LdapSettingsAdvancedProps) => {
const { t } = useTranslation("user-federation");
2021-12-14 14:56:36 +00:00
const { t: helpText } = useTranslation("user-federation-help");
2020-11-25 14:50:40 +00:00
return (
<>
{showSectionHeading && (
<WizardSectionHeader
title={t("advancedSettings")}
description={helpText("ldapAdvancedSettingsDescription")}
showDescription={showSectionDescription}
/>
)}
2020-11-25 16:17:50 +00:00
<FormAccess role="manage-realm" isHorizontal>
<FormGroup
label={t("enableLdapv3Password")}
labelIcon={
<HelpItem
helpText="user-federation-help:enableLdapv3PasswordHelp"
fieldLabelId="user-federation:enableLdapv3Password"
/>
}
fieldId="kc-enable-ldapv3-password"
hasNoPaddingTop
>
2020-11-25 14:50:40 +00:00
<Controller
name="config.usePasswordModifyExtendedOp"
defaultValue={["false"]}
control={form.control}
2020-11-25 14:50:40 +00:00
render={({ onChange, value }) => (
<Switch
id={"kc-enable-ldapv3-password"}
isDisabled={false}
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>
</FormGroup>
<FormGroup
label={t("validatePasswordPolicy")}
labelIcon={
<HelpItem
helpText="user-federation-help:validatePasswordPolicyHelp"
fieldLabelId="user-federation:validatePasswordPolicy"
/>
}
fieldId="kc-validate-password-policy"
hasNoPaddingTop
>
2020-11-25 14:50:40 +00:00
<Controller
name="config.validatePasswordPolicy"
2021-02-19 23:13:07 +00:00
defaultValue={["false"]}
control={form.control}
2020-11-25 14:50:40 +00:00
render={({ onChange, value }) => (
<Switch
id={"kc-validate-password-policy"}
isDisabled={false}
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>
</FormGroup>
<FormGroup
label={t("trustEmail")}
labelIcon={
<HelpItem
helpText="user-federation-help:trustEmailHelp"
fieldLabelId="user-federation:trustEmail"
/>
}
fieldId="kc-trust-email"
hasNoPaddingTop
>
2020-11-25 14:50:40 +00:00
<Controller
name="config.trustEmail"
2021-02-19 23:13:07 +00:00
defaultValue={["false"]}
control={form.control}
2020-11-25 14:50:40 +00:00
render={({ onChange, value }) => (
<Switch
id={"kc-trust-email"}
isDisabled={false}
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>
</FormGroup>
2020-11-25 16:17:50 +00:00
</FormAccess>
</>
);
};