import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation"; import React, { useMemo, useState } from "react"; import { useTranslation } from "react-i18next"; import { FormGroup, TextInput, Form, Switch, TextArea, Select, SelectVariant, SelectOption, ValidatedOptions, } from "@patternfly/react-core"; import { Controller, useFormContext } from "react-hook-form"; import { ScrollForm } from "../components/scroll-form/ScrollForm"; import { ClientDescription } from "./ClientDescription"; import { CapabilityConfig } from "./add/CapabilityConfig"; import { MultiLineInput } from "../components/multi-line-input/MultiLineInput"; import { FormAccess } from "../components/form-access/FormAccess"; import { HelpItem } from "../components/help-enabler/HelpItem"; import { useServerInfo } from "../context/server-info/ServerInfoProvider"; import { SaveReset } from "./advanced/SaveReset"; import { SamlConfig } from "./add/SamlConfig"; import { SamlSignature } from "./add/SamlSignature"; import type { ClientForm } from "./ClientDetails"; type ClientSettingsProps = { client: ClientRepresentation; save: () => void; reset: () => void; }; export const ClientSettings = ({ client, save, reset, }: ClientSettingsProps) => { const { register, control, watch, errors } = useFormContext(); const { t } = useTranslation("clients"); const [loginThemeOpen, setLoginThemeOpen] = useState(false); const loginThemes = useServerInfo().themes!["login"]; const consentRequired = watch("consentRequired"); const displayOnConsentScreen: string = watch( "attributes.display.on.consent.screen" ); const protocol = watch("protocol"); const frontchannelLogout = watch("frontchannelLogout"); const sections = useMemo(() => { let result = ["generalSettings"]; if (protocol === "saml") { result = [...result, "samlCapabilityConfig", "signatureAndEncryption"]; } else if (!client.bearerOnly) { result = [...result, "capabilityConfig"]; } else { return [...result, "accessSettings"]; } return [...result, "accessSettings", "loginSettings", "logoutSettings"]; }, [protocol, client]); return ( t(section))} >
{protocol === "saml" ? ( ) : ( !client.bearerOnly && )} {protocol === "saml" && } {!client.bearerOnly && ( <> } > } > } > } > )} } > {client.bearerOnly && ( )} } fieldId="loginTheme" > ( )} /> } fieldId="kc-consent" hasNoPaddingTop > ( )} /> } fieldId="kc-display-on-client" hasNoPaddingTop > ( onChange("" + value)} isDisabled={!consentRequired} /> )} /> } fieldId="kc-consent-screen-text" >