UNPKG

@keycloakify/keycloak-admin-ui

Version:
41 lines 3.4 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { ExpandableSection } from "@patternfly/react-core"; import { useState } from "react"; import { useFormContext, useWatch } from "react-hook-form"; import { useTranslation } from "react-i18next"; import { SelectControl, TextAreaControl, TextControl, } from "../../ui-shared"; import { DefaultSwitchControl } from "../../components/SwitchControl"; import "./discovery-settings.css"; const PKCE_METHODS = ["plain", "S256"]; const Fields = ({ readOnly }) => { const { t } = useTranslation(); const { control } = useFormContext(); const validateSignature = useWatch({ control, name: "config.validateSignature", }); const useJwks = useWatch({ control, name: "config.useJwksUrl", }); const isPkceEnabled = useWatch({ control, name: "config.pkceEnabled", }); return (_jsxs("div", { className: "pf-v5-c-form pf-m-horizontal", children: [_jsx(TextControl, { name: "config.authorizationUrl", label: t("authorizationUrl"), type: "url", readOnly: readOnly, rules: { required: t("required"), } }), _jsx(TextControl, { name: "config.tokenUrl", label: t("tokenUrl"), type: "url", readOnly: readOnly, rules: { required: t("required"), } }), _jsx(TextControl, { name: "config.logoutUrl", label: t("logoutUrl"), readOnly: readOnly }), _jsx(TextControl, { name: "config.userInfoUrl", label: t("userInfoUrl"), readOnly: readOnly }), _jsx(TextControl, { name: "config.issuer", label: t("issuer"), readOnly: readOnly }), _jsx(DefaultSwitchControl, { name: "config.validateSignature", label: t("validateSignature"), isDisabled: readOnly, stringify: true }), validateSignature === "true" && (_jsxs(_Fragment, { children: [_jsx(DefaultSwitchControl, { name: "config.useJwksUrl", label: t("useJwksUrl"), isDisabled: readOnly, stringify: true }), useJwks === "true" ? (_jsx(TextAreaControl, { name: "config.jwksUrl", label: t("jwksUrl"), readOnly: readOnly })) : (_jsxs(_Fragment, { children: [_jsx(TextControl, { name: "config.publicKeySignatureVerifier", label: "validatingPublicKey" }), _jsx(TextControl, { name: "config.publicKeySignatureVerifierKeyId", label: t("validatingPublicKeyId"), readOnly: readOnly })] }))] })), _jsx(DefaultSwitchControl, { name: "config.pkceEnabled", label: t("pkceEnabled"), isDisabled: readOnly, stringify: true }), isPkceEnabled === "true" && (_jsx(SelectControl, { name: "config.pkceMethod", label: t("pkceMethod"), labelIcon: t("pkceMethodHelp"), controller: { defaultValue: PKCE_METHODS[0], }, options: PKCE_METHODS.map((option) => ({ key: option, value: t(option), })) }))] })); }; export const DiscoverySettings = ({ readOnly }) => { const { t } = useTranslation(); const [isExpanded, setIsExpanded] = useState(false); return (_jsxs(_Fragment, { children: [readOnly && (_jsx(ExpandableSection, { className: "keycloak__discovery-settings__metadata", toggleText: isExpanded ? t("hideMetaData") : t("showMetaData"), onToggle: () => setIsExpanded(!isExpanded), isExpanded: isExpanded, children: _jsx(Fields, { readOnly: readOnly }) })), !readOnly && _jsx(Fields, { readOnly: readOnly })] })); }; //# sourceMappingURL=DiscoverySettings.js.map