import React from "react"; import { useTranslation } from "react-i18next"; import { Controller, useFormContext, useWatch } from "react-hook-form"; import { ActionGroup, Button, FormGroup, NumberInput, Switch, } from "@patternfly/react-core"; import type RealmRepresentation from "keycloak-admin/lib/defs/realmRepresentation"; import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { Time } from "./Time"; type BruteForceDetectionProps = { save: (realm: RealmRepresentation) => void; reset: () => void; }; export const BruteForceDetection = ({ save, reset, }: BruteForceDetectionProps) => { const { t } = useTranslation("realm-settings"); const { handleSubmit, control, formState: { isDirty }, } = useFormContext(); const enable = useWatch({ control, name: "bruteForceProtected", }); const permanentLockout = useWatch({ control, name: "permanentLockout", }); return ( ( )} /> {enable && ( <> } fieldId="failureFactor" > ( onChange(value + 1)} onMinus={() => onChange(value - 1)} onChange={(event) => onChange(Number((event.target as HTMLInputElement).value)) } /> )} /> ( )} /> {permanentLockout && ( <> ); };