@keycloakify/keycloak-admin-ui
Version:
Repackaged Keycloak Admin UI
41 lines • 5.25 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { HelpItem, SelectControl, TextControl, } from "../../ui-shared";
import { FormGroup, Switch } from "@patternfly/react-core";
import { isEqual } from "lodash-es";
import { useEffect } from "react";
import { Controller, FormProvider, useWatch, } from "react-hook-form";
import { useTranslation } from "react-i18next";
import { FormAccess } from "../../components/form/FormAccess";
import { WizardSectionHeader } from "../../components/wizard-section-header/WizardSectionHeader";
import { useRealm } from "../../context/realm-context/RealmContext";
export const KerberosSettingsRequired = ({ form, showSectionHeading = false, showSectionDescription = false, }) => {
const { t } = useTranslation();
const { realm, realmRepresentation } = useRealm();
const allowPassAuth = useWatch({
control: form.control,
name: "config.allowPasswordAuthentication",
});
useEffect(() => form.setValue("parentId", realmRepresentation === null || realmRepresentation === void 0 ? void 0 : realmRepresentation.id), []);
return (_jsxs(FormProvider, { ...form, children: [showSectionHeading && (_jsx(WizardSectionHeader, { title: t("requiredSettings"), description: t("kerberosRequiredSettingsDescription"), showDescription: showSectionDescription })), _jsxs(FormAccess, { role: "manage-realm", isHorizontal: true, children: [_jsx("input", { type: "hidden", defaultValue: "kerberos", ...form.register("providerId") }), _jsx("input", { type: "hidden", defaultValue: "org.keycloak.storage.UserStorageProvider", ...form.register("providerType") }), _jsx("input", { type: "hidden", defaultValue: realm, ...form.register("parentId") }), _jsx(TextControl, { name: "name", label: t("uiDisplayName"), labelIcon: t("uiDisplayNameHelp"), rules: {
required: t("validateName"),
} }), _jsx(TextControl, { name: "config.kerberosRealm.0", label: t("kerberosRealm"), labelIcon: t("kerberosRealmHelp"), rules: {
required: t("validateRealm"),
} }), _jsx(TextControl, { name: "config.serverPrincipal.0", label: t("serverPrincipal"), labelIcon: t("serverPrincipalHelp"), rules: {
required: t("validateServerPrincipal"),
} }), _jsx(TextControl, { name: "config.keyTab.0", label: t("keyTab"), labelIcon: t("keyTabHelp"), rules: {
required: t("validateKeyTab"),
} }), _jsx(FormGroup, { label: t("debug"), labelIcon: _jsx(HelpItem, { helpText: t("debugHelp"), fieldLabelId: "debug" }), fieldId: "kc-debug", hasNoPaddingTop: true, children: _jsx(Controller, { name: "config.debug", defaultValue: ["false"], control: form.control, render: ({ field }) => {
var _a;
return (_jsx(Switch, { id: "kc-debug", "data-testid": "debug", onChange: (_event, value) => field.onChange([`${value}`]), isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a[0]) === "true", label: t("on"), labelOff: t("off"), "aria-label": t("debug") }));
} }) }), _jsx(FormGroup, { label: t("allowPasswordAuthentication"), labelIcon: _jsx(HelpItem, { helpText: t("allowPasswordAuthenticationHelp"), fieldLabelId: "allowPasswordAuthentication" }), fieldId: "kc-allow-password-authentication", hasNoPaddingTop: true, children: _jsx(Controller, { name: "config.allowPasswordAuthentication", defaultValue: ["false"], control: form.control, render: ({ field }) => {
var _a;
return (_jsx(Switch, { id: "kc-allow-password-authentication", "data-testid": "allow-password-authentication", onChange: (_event, value) => field.onChange([`${value}`]), isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a[0]) === "true", label: t("on"), labelOff: t("off"), "aria-label": t("allowPasswordAuthentication") }));
} }) }), isEqual(allowPassAuth, ["true"]) ? (_jsx(SelectControl, { name: "config.editMode[0]", label: t("editMode"), labelIcon: t("editModeKerberosHelp"), controller: {
rules: { required: t("required") },
defaultValue: "READ_ONLY",
}, options: ["READ_ONLY", "UNSYNCED"] })) : null, _jsx(FormGroup, { label: t("updateFirstLogin"), labelIcon: _jsx(HelpItem, { helpText: t("updateFirstLoginHelp"), fieldLabelId: "updateFirstLogin" }), fieldId: "kc-update-first-login", hasNoPaddingTop: true, children: _jsx(Controller, { name: "config.updateProfileFirstLogin", defaultValue: ["false"], control: form.control, render: ({ field }) => {
var _a;
return (_jsx(Switch, { id: "kc-update-first-login", "data-testid": "update-first-login", onChange: (_event, value) => field.onChange([`${value}`]), isChecked: ((_a = field.value) === null || _a === void 0 ? void 0 : _a[0]) === "true", label: t("on"), labelOff: t("off"), "aria-label": t("updateFirstLogin") }));
} }) })] })] }));
};
//# sourceMappingURL=KerberosSettingsRequired.js.map