@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
42 lines • 8.12 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
import { Checkbox, FormGroup, Grid, GridItem, InputGroup, Switch, InputGroupItem, } from "@patternfly/react-core";
import { Controller, useFormContext } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { HelpItem } from "../../ui-shared";
import { DefaultSwitchControl } from "../../components/SwitchControl";
import { FormAccess } from "../../components/form/FormAccess";
import { convertAttributeNameToForm } from "../../util";
import useIsFeatureEnabled, { Feature } from "../../utils/useIsFeatureEnabled";
export const CapabilityConfig = ({ unWrap, protocol: type, }) => {
const { t } = useTranslation();
const { control, watch, setValue } = useFormContext();
const protocol = type || watch("protocol");
const clientAuthentication = watch("publicClient");
const authorization = watch("authorizationServicesEnabled");
const isFeatureEnabled = useIsFeatureEnabled();
return (_jsxs(FormAccess, { isHorizontal: true, role: "manage-clients", unWrap: unWrap, className: "keycloak__capability-config__form", "data-testid": "capability-config-form", children: [protocol === "openid-connect" && (_jsxs(_Fragment, { children: [_jsx(FormGroup, { hasNoPaddingTop: true, label: t("clientAuthentication"), fieldId: "kc-authentication", labelIcon: _jsx(HelpItem, { helpText: t("authenticationHelp"), fieldLabelId: "authentication" }), children: _jsx(Controller, { name: "publicClient", defaultValue: false, control: control, render: ({ field }) => (_jsx(Switch, { "data-testid": "authentication", id: "kc-authentication-switch", label: t("on"), labelOff: t("off"), isChecked: !field.value, onChange: (_event, value) => {
field.onChange(!value);
if (!value) {
setValue("authorizationServicesEnabled", false);
setValue("serviceAccountsEnabled", false);
setValue(convertAttributeNameToForm("attributes.oidc.ciba.grant.enabled"), false);
}
}, "aria-label": t("clientAuthentication") })) }) }), _jsx(FormGroup, { hasNoPaddingTop: true, label: t("clientAuthorization"), fieldId: "kc-authorization", labelIcon: _jsx(HelpItem, { helpText: t("authorizationHelp"), fieldLabelId: "authorization" }), children: _jsx(Controller, { name: "authorizationServicesEnabled", defaultValue: false, control: control, render: ({ field }) => (_jsx(Switch, { "data-testid": "authorization", id: "kc-authorization-switch", label: t("on"), labelOff: t("off"), isChecked: field.value && !clientAuthentication, onChange: (_event, value) => {
field.onChange(value);
if (value) {
setValue("serviceAccountsEnabled", true);
}
}, isDisabled: clientAuthentication, "aria-label": t("clientAuthorization") })) }) }), _jsx(FormGroup, { hasNoPaddingTop: true, label: t("authenticationFlow"), fieldId: "kc-flow", children: _jsxs(Grid, { id: "authenticationFlowGrid", hasGutter: true, children: [_jsx(GridItem, { lg: 4, sm: 6, children: _jsx(Controller, { name: "standardFlowEnabled", defaultValue: true, control: control, render: ({ field }) => {
var _a;
return (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "standard", label: t("standardFlow"), id: "kc-flow-standard", isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === "true", onChange: field.onChange }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("standardFlowHelp"), fieldLabelId: "standardFlow" }) })] }));
} }) }), _jsx(GridItem, { lg: 8, sm: 6, children: _jsx(Controller, { name: "directAccessGrantsEnabled", defaultValue: true, control: control, render: ({ field }) => (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "direct", label: t("directAccess"), id: "kc-flow-direct", isChecked: field.value, onChange: field.onChange }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("directAccessHelp"), fieldLabelId: "directAccess" }) })] })) }) }), _jsx(GridItem, { lg: 4, sm: 6, children: _jsx(Controller, { name: "implicitFlowEnabled", defaultValue: true, control: control, render: ({ field }) => {
var _a;
return (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "implicit", label: t("implicitFlow"), id: "kc-flow-implicit", isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === "true", onChange: field.onChange }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("implicitFlowHelp"), fieldLabelId: "implicitFlow" }) })] }));
} }) }), _jsx(GridItem, { lg: 8, sm: 6, children: _jsx(Controller, { name: "serviceAccountsEnabled", defaultValue: false, control: control, render: ({ field }) => {
var _a;
return (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "service-account", label: t("serviceAccount"), id: "kc-flow-service-account", isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a.toString()) === "true" ||
(clientAuthentication && authorization), onChange: field.onChange, isDisabled: (clientAuthentication && !authorization) ||
(!clientAuthentication && authorization) }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("serviceAccountHelp"), fieldLabelId: "serviceAccount" }) })] }));
} }) }), isFeatureEnabled(Feature.DeviceFlow) && (_jsx(GridItem, { lg: 8, sm: 6, children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.oauth2.device.authorization.grant.enabled"), defaultValue: false, control: control, render: ({ field }) => (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "oauth-device-authorization-grant", label: t("oauthDeviceAuthorizationGrant"), id: "kc-oauth-device-authorization-grant", name: "oauth2.device.authorization.grant.enabled", isChecked: field.value.toString() === "true", onChange: field.onChange }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("oauthDeviceAuthorizationGrantHelp"), fieldLabelId: "oauthDeviceAuthorizationGrant" }) })] })) }) })), _jsx(GridItem, { lg: 8, sm: 6, children: _jsx(Controller, { name: convertAttributeNameToForm("attributes.oidc.ciba.grant.enabled"), defaultValue: false, control: control, render: ({ field }) => (_jsxs(InputGroup, { children: [_jsx(InputGroupItem, { children: _jsx(Checkbox, { "data-testid": "oidc-ciba-grant", label: t("oidcCibaGrant"), id: "kc-oidc-ciba-grant", name: "oidc.ciba.grant.enabled", isChecked: field.value.toString() === "true", onChange: field.onChange, isDisabled: clientAuthentication }) }), _jsx(InputGroupItem, { children: _jsx(HelpItem, { helpText: t("oidcCibaGrantHelp"), fieldLabelId: "oidcCibaGrant" }) })] })) }) })] }) })] })), protocol === "saml" && (_jsxs(_Fragment, { children: [_jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.saml.encrypt"), label: t("encryptAssertions"), labelIcon: t("encryptAssertionsHelp") }), _jsx(DefaultSwitchControl, { name: convertAttributeNameToForm("attributes.saml.client.signature"), label: t("clientSignature"), labelIcon: t("clientSignatureHelp") })] }))] }));
};
//# sourceMappingURL=CapabilityConfig.js.map