import React, { useState } from "react"; import { useTranslation } from "react-i18next"; import { useFormContext, useWatch } from "react-hook-form"; import { ExpandableSection, FormGroup, TextInput, ValidatedOptions, } from "@patternfly/react-core"; import { SwitchField } from "../component/SwitchField"; import { TextField } from "../component/TextField"; import "./discovery-settings.css"; type DiscoverySettingsProps = { readOnly: boolean; }; const Fields = ({ readOnly }: DiscoverySettingsProps) => { const { t } = useTranslation("identity-providers"); const { register, control, errors } = useFormContext(); const validateSignature = useWatch({ control: control, name: "config.validateSignature", }); const useJwks = useWatch({ control: control, name: "config.useJwksUrl", }); return (
{validateSignature === "true" && ( <> {useJwks === "true" && ( )} )}
); }; export const DiscoverySettings = ({ readOnly }: DiscoverySettingsProps) => { const { t } = useTranslation("identity-providers"); const [isExpanded, setIsExpanded] = useState(false); return ( <> {readOnly && ( setIsExpanded(!isExpanded)} isExpanded={isExpanded} > )} {!readOnly && } ); };