import React from "react"; import { useTranslation } from "react-i18next"; import { Controller, useFormContext } from "react-hook-form"; import { FormGroup, Switch, ValidatedOptions } from "@patternfly/react-core"; import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation"; import type { ClientSettingsProps } from "../ClientSettings"; import { FormAccess } from "../../components/form-access/FormAccess"; import { HelpItem } from "../../components/help-enabler/HelpItem"; import { KeycloakTextInput } from "../../components/keycloak-text-input/KeycloakTextInput"; import { useAccess } from "../../context/access/Access"; import { SaveReset } from "../advanced/SaveReset"; export const LogoutPanel = ({ save, reset, client: { access }, }: ClientSettingsProps) => { const { t } = useTranslation("clients"); const { register, control, watch, formState: { errors }, } = useFormContext(); const { hasAccess } = useAccess(); const isManager = hasAccess("manage-clients") || access?.configure; const protocol = watch("protocol"); const frontchannelLogout = watch("frontchannelLogout"); return ( } fieldId="kc-frontchannelLogout" hasNoPaddingTop > ( )} /> {protocol === "openid-connect" && frontchannelLogout && ( } helperTextInvalid={ errors.attributes?.frontchannel?.logout?.url?.message } validated={ errors.attributes?.frontchannel?.logout?.url?.message ? ValidatedOptions.error : ValidatedOptions.default } > ((uri.startsWith("https://") || uri.startsWith("http://")) && !uri.includes("*")) || uri === "" || t("frontchannelUrlInvalid").toString(), })} validated={ errors.attributes?.frontchannel?.logout?.url?.message ? ValidatedOptions.error : ValidatedOptions.default } /> )} } helperTextInvalid={errors.attributes?.backchannel?.logout?.url?.message} validated={ errors.attributes?.backchannel?.logout?.url?.message ? ValidatedOptions.error : ValidatedOptions.default } > ((uri.startsWith("https://") || uri.startsWith("http://")) && !uri.includes("*")) || uri === "" || t("backchannelUrlInvalid").toString(), })} validated={ errors.attributes?.backchannel?.logout?.url?.message ? ValidatedOptions.error : ValidatedOptions.default } /> } fieldId="backchannelLogoutSessionRequired" hasNoPaddingTop > ( onChange(value.toString())} /> )} /> } fieldId="backchannelLogoutRevokeOfflineSessions" hasNoPaddingTop > ( onChange(value.toString())} /> )} /> ); };