import { FormGroup, Select, SelectOption, SelectVariant, TextInput, } from "@patternfly/react-core"; import { useTranslation } from "react-i18next"; import React, { useState } from "react"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { UseFormMethods, useWatch, Controller } from "react-hook-form"; import { FormAccess } from "../../components/form-access/FormAccess"; import _ from "lodash"; import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader"; export type LdapSettingsCacheProps = { form: UseFormMethods; showSectionHeading?: boolean; showSectionDescription?: boolean; }; export const LdapSettingsCache = ({ form, showSectionHeading = false, showSectionDescription = false, }: LdapSettingsCacheProps) => { const { t } = useTranslation("user-federation"); const helpText = useTranslation("user-federation-help").t; const [isCachePolicyDropdownOpen, setIsCachePolicyDropdownOpen] = useState( false ); const [isEvictionHourDropdownOpen, setIsEvictionHourDropdownOpen] = useState( false ); const cachePolicyType = useWatch({ control: form.control, name: "config.cachePolicy", }); const [ isEvictionMinuteDropdownOpen, setIsEvictionMinuteDropdownOpen, ] = useState(false); const [isEvictionDayDropdownOpen, setIsEvictionDayDropdownOpen] = useState( false ); const hourOptions = []; for (let index = 2; index <= 24; index++) { hourOptions.push(); } const minuteOptions = [ , ]; for (let index = 2; index <= 60; index++) { minuteOptions.push(); } return ( <> {showSectionHeading && ( )} } fieldId="kc-cache-policy" > ( )} > {_.isEqual(cachePolicyType, ["EVICT_WEEKLY"]) ? ( } isRequired fieldId="kc-eviction-day" > ( )} > ) : ( <> )} {_.isEqual(cachePolicyType, ["EVICT_DAILY"]) || _.isEqual(cachePolicyType, ["EVICT_WEEKLY"]) ? ( <> } isRequired fieldId="kc-eviction-hour" > ( )} > } isRequired fieldId="kc-eviction-minute" > ( )} > ) : ( <> )} {_.isEqual(cachePolicyType, ["MAX_LIFESPAN"]) ? ( } fieldId="kc-max-lifespan" > ) : ( <> )} ); };