UNPKG

@keycloakify/keycloak-admin-ui

Version:
24 lines 2.33 kB
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime"; import { HelpItem, KeycloakSelect, SelectControl, SelectVariant, TextControl, } from "../../ui-shared"; import { FormGroup, SelectOption } from "@patternfly/react-core"; import { useState } from "react"; import { Controller } from "react-hook-form"; import { useTranslation } from "react-i18next"; export const AddMapperForm = ({ mapperTypes, mapperType, form, id, updateMapperType, }) => { const { t } = useTranslation(); const { control } = form; const [mapperTypeOpen, setMapperTypeOpen] = useState(false); const syncModes = ["inherit", "import", "legacy", "force"]; return (_jsxs(_Fragment, { children: [_jsx(TextControl, { name: "name", label: t("name"), labelIcon: t("addIdpMapperNameHelp"), readOnly: !!id, rules: { required: t("required"), } }), _jsx(SelectControl, { name: "config.syncMode", label: t("syncModeOverride"), labelIcon: t("syncModeOverrideHelp"), options: syncModes.map((option) => ({ key: option.toUpperCase(), value: t(`syncModes.${option}`), })), controller: { defaultValue: syncModes[0].toUpperCase() } }), _jsx(FormGroup, { label: t("mapperType"), labelIcon: _jsx(HelpItem, { helpText: mapperType.helpText, fieldLabelId: "mapperType" }), fieldId: "identityProviderMapper", children: _jsx(Controller, { name: "identityProviderMapper", defaultValue: mapperTypes[0].id, control: control, render: ({ field }) => (_jsx(KeycloakSelect, { toggleId: "identityProviderMapper", "data-testid": "idp-mapper-select", isDisabled: !!id, onToggle: () => setMapperTypeOpen(!mapperTypeOpen), onSelect: (value) => { const mapperType = value; updateMapperType(mapperType); field.onChange(mapperType.id); setMapperTypeOpen(false); }, selections: mapperType.name, variant: SelectVariant.single, "aria-label": t("mapperType"), isOpen: mapperTypeOpen, children: mapperTypes.map((option) => (_jsx(SelectOption, { selected: option === field.value, "datatest-id": option.id, value: option, children: option.name }, option.name))) })) }) })] })); }; //# sourceMappingURL=AddMapperForm.js.map