@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
27 lines • 4.33 kB
JavaScript
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
import { FormGroup, Switch } from "@patternfly/react-core";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem, TextControl } from "../../ui-shared";
import { FixedButtonsGroup } from "../../components/form/FixedButtonGroup";
import { FormAccess } from "../../components/form/FormAccess";
import { useAccess } from "../../context/access/Access";
import { convertAttributeNameToForm } from "../../util";
const validateUrl = (uri, error) => (((uri === null || uri === void 0 ? void 0 : uri.startsWith("https://")) || (uri === null || uri === void 0 ? void 0 : uri.startsWith("http://"))) &&
!uri.includes("*")) ||
uri === "" ||
error;
export const LogoutPanel = ({ save, reset, client: { access }, }) => {
const { t } = useTranslation();
const { control, watch } = useFormContext();
const { hasAccess } = useAccess();
const isManager = hasAccess("manage-clients") || (access === null || access === void 0 ? void 0 : access.configure);
const protocol = watch("protocol");
const frontchannelLogout = watch("frontchannelLogout");
return (_jsxs(FormAccess, { isHorizontal: true, fineGrainedAccess: access === null || access === void 0 ? void 0 : access.configure, role: "manage-clients", children: [_jsx(FormGroup, { label: t("frontchannelLogout"), labelIcon: _jsx(HelpItem, { helpText: t("frontchannelLogoutHelp"), fieldLabelId: "frontchannelLogout" }), fieldId: "kc-frontchannelLogout", hasNoPaddingTop: true, children: _jsx(Controller, { name: "frontchannelLogout", defaultValue: true, control: control, render: ({ field }) => (_jsx(Switch, { id: "kc-frontchannelLogout-switch", label: t("on"), labelOff: t("off"), isChecked: field.value, onChange: field.onChange, "aria-label": t("frontchannelLogout") })) }) }), protocol === "openid-connect" && frontchannelLogout && (_jsx(TextControl, { "data-testid": "frontchannelLogoutUrl", type: "url", name: convertAttributeNameToForm("attributes.frontchannel.logout.url"), label: t("frontchannelLogoutUrl"), labelIcon: t("frontchannelLogoutUrlHelp"), rules: {
validate: (uri) => validateUrl(uri, t("frontchannelUrlInvalid").toString()),
} })), protocol === "openid-connect" && (_jsxs(_Fragment, { children: [_jsx(TextControl, { "data-testid": "backchannelLogoutUrl", type: "url", name: convertAttributeNameToForm("attributes.backchannel.logout.url"), label: t("backchannelLogoutUrl"), labelIcon: t("backchannelLogoutUrlHelp"), rules: {
validate: (uri) => validateUrl(uri, t("backchannelUrlInvalid").toString()),
} }), _jsx(FormGroup, { label: t("backchannelLogoutSessionRequired"), labelIcon: _jsx(HelpItem, { helpText: t("backchannelLogoutSessionRequiredHelp"), fieldLabelId: "backchannelLogoutSessionRequired" }), fieldId: "backchannelLogoutSessionRequired", hasNoPaddingTop: true, children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.backchannel.logout.session.required"), defaultValue: "true", control: control, render: ({ field }) => (_jsx(Switch, { id: "backchannelLogoutSessionRequired", label: t("on"), labelOff: t("off"), isChecked: field.value === "true", onChange: (_event, value) => field.onChange(value.toString()), "aria-label": t("backchannelLogoutSessionRequired") })) }) }), _jsx(FormGroup, { label: t("backchannelLogoutRevokeOfflineSessions"), labelIcon: _jsx(HelpItem, { helpText: t("backchannelLogoutRevokeOfflineSessionsHelp"), fieldLabelId: "backchannelLogoutRevokeOfflineSessions" }), fieldId: "backchannelLogoutRevokeOfflineSessions", hasNoPaddingTop: true, children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.backchannel.logout.revoke.offline.tokens"), defaultValue: "false", control: control, render: ({ field }) => (_jsx(Switch, { id: "backchannelLogoutRevokeOfflineSessions", label: t("on"), labelOff: t("off"), isChecked: field.value === "true", onChange: (_event, value) => field.onChange(value.toString()), "aria-label": t("backchannelLogoutRevokeOfflineSessions") })) }) })] })), _jsx(FixedButtonsGroup, { name: "settings", save: save, reset: reset, isDisabled: !isManager })] }));
};
//# sourceMappingURL=LogoutPanel.js.map