import { FormGroup, Switch, ValidatedOptions } from "@patternfly/react-core"; import { Controller, useFormContext } from "react-hook-form-v7"; import { useTranslation } from "react-i18next"; 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 { beerify, convertAttributeNameToForm } from "../../util"; import { SaveReset } from "../advanced/SaveReset"; import type { ClientSettingsProps } from "../ClientSettings"; import { FormFields } from "../ClientDetails"; 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?.[beerify("frontchannel.logout.url")]?.message } validated={ errors.attributes?.[beerify("frontchannel.logout.url")]?.message ? ValidatedOptions.error : ValidatedOptions.default } > ( "attributes.frontchannel.logout.url" ), { validate: (uri) => ((uri.startsWith("https://") || uri.startsWith("http://")) && !uri.includes("*")) || uri === "" || t("frontchannelUrlInvalid").toString(), } )} validated={ errors.attributes?.[beerify("frontchannel.logout.url")]?.message ? ValidatedOptions.error : ValidatedOptions.default } /> )} {protocol === "openid-connect" && ( <> } helperTextInvalid={ errors.attributes?.[beerify("backchannel.logout.url")]?.message } validated={ errors.attributes?.[beerify("backchannel.logout.url")]?.message ? ValidatedOptions.error : ValidatedOptions.default } > ( "attributes.backchannel.logout.url" ), { validate: (uri) => ((uri.startsWith("https://") || uri.startsWith("http://")) && !uri.includes("*")) || uri === "" || t("backchannelUrlInvalid").toString(), } )} validated={ errors.attributes?.[beerify("backchannel.logout.url")]?.message ? ValidatedOptions.error : ValidatedOptions.default } /> } fieldId="backchannelLogoutSessionRequired" hasNoPaddingTop > ( "attributes.backchannel.logout.session.required" )} defaultValue="true" control={control} render={({ field }) => ( field.onChange(value.toString())} aria-label={t("backchannelLogoutSessionRequired")} /> )} /> } fieldId="backchannelLogoutRevokeOfflineSessions" hasNoPaddingTop > ( "attributes.backchannel.logout.revoke.offline.tokens" )} defaultValue="false" control={control} render={({ field }) => ( field.onChange(value.toString())} aria-label={t("backchannelLogoutRevokeOfflineSessions")} /> )} /> )} ); };