theme.keycloak.v2.admin.resources.assets.LdapMapperDetails-DzbSqiQ5.js.map Maven / Gradle / Ivy
{"version":3,"file":"LdapMapperDetails-DzbSqiQ5.js","sources":["../../src/user-federation/ldap/mappers/LdapMapperDetails.tsx"],"sourcesContent":["import type ComponentRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/componentRepresentation\";\nimport type ComponentTypeRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/componentTypeRepresentation\";\nimport { DirectionType } from \"@keycloak/keycloak-admin-client/lib/resources/userStorageProvider\";\nimport {\n HelpItem,\n KeycloakSelect,\n SelectVariant,\n TextControl,\n} from \"@keycloak/keycloak-ui-shared\";\nimport {\n ActionGroup,\n AlertVariant,\n Button,\n ButtonVariant,\n DropdownItem,\n FormGroup,\n PageSection,\n SelectOption,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { Controller, FormProvider, useForm, useWatch } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate } from \"react-router-dom\";\nimport { useAdminClient } from \"../../../admin-client\";\nimport { useAlerts } from \"../../../components/alert/Alerts\";\nimport { useConfirmDialog } from \"../../../components/confirm-dialog/ConfirmDialog\";\nimport {\n DynamicComponents,\n convertToName,\n} from \"../../../components/dynamic/DynamicComponents\";\nimport { FormAccess } from \"../../../components/form/FormAccess\";\nimport { KeycloakSpinner } from \"../../../components/keycloak-spinner/KeycloakSpinner\";\nimport { ViewHeader } from \"../../../components/view-header/ViewHeader\";\nimport { useRealm } from \"../../../context/realm-context/RealmContext\";\nimport { convertFormValuesToObject, convertToFormValues } from \"../../../util\";\nimport { useFetch } from \"../../../utils/useFetch\";\nimport { useParams } from \"../../../utils/useParams\";\nimport { toUserFederationLdap } from \"../../routes/UserFederationLdap\";\nimport { UserFederationLdapMapperParams } from \"../../routes/UserFederationLdapMapper\";\n\nexport default function LdapMapperDetails() {\n const { adminClient } = useAdminClient();\n\n const form = useForm();\n const [mapping, setMapping] = useState();\n const [components, setComponents] = useState();\n\n const { id, mapperId } = useParams();\n const navigate = useNavigate();\n const { realm } = useRealm();\n const { t } = useTranslation();\n const { addAlert, addError } = useAlerts();\n\n const [isMapperDropdownOpen, setIsMapperDropdownOpen] = useState(false);\n const [key, setKey] = useState(0);\n const refresh = () => setKey(key + 1);\n\n useFetch(\n async () => {\n const components = await adminClient.components.listSubComponents({\n id,\n type: \"org.keycloak.storage.ldap.mappers.LDAPStorageMapper\",\n });\n if (mapperId && mapperId !== \"new\") {\n const fetchedMapper = await adminClient.components.findOne({\n id: mapperId,\n });\n return { components, fetchedMapper };\n }\n return { components };\n },\n ({ components, fetchedMapper }) => {\n setMapping(fetchedMapper);\n setComponents(components);\n if (mapperId !== \"new\" && !fetchedMapper) throw new Error(t(\"notFound\"));\n\n if (fetchedMapper) setupForm(fetchedMapper);\n },\n [],\n );\n\n const setupForm = (mapper: ComponentRepresentation) => {\n convertToFormValues(mapper, form.setValue);\n };\n\n const save = async (mapper: ComponentRepresentation) => {\n const component: ComponentRepresentation =\n convertFormValuesToObject(mapper);\n const map = {\n ...component,\n config: Object.entries(component.config || {}).reduce(\n (result, [key, value]) => {\n result[key] = Array.isArray(value) ? value : [value];\n return result;\n },\n {} as Record,\n ),\n };\n\n try {\n if (mapperId === \"new\") {\n await adminClient.components.create(map);\n navigate(\n toUserFederationLdap({ realm, id: mapper.parentId!, tab: \"mappers\" }),\n );\n } else {\n await adminClient.components.update({ id: mapperId }, map);\n }\n setupForm(map as ComponentRepresentation);\n addAlert(\n t(\n mapperId === \"new\"\n ? \"mappingCreatedSuccess\"\n : \"mappingUpdatedSuccess\",\n ),\n AlertVariant.success,\n );\n } catch (error) {\n addError(\n mapperId === \"new\" ? \"mappingCreatedError\" : \"mappingUpdatedError\",\n error,\n );\n }\n };\n\n const sync = async (direction: DirectionType) => {\n try {\n const result = await adminClient.userStorageProvider.mappersSync({\n parentId: mapping?.parentId || \"\",\n id: mapperId,\n direction,\n });\n addAlert(\n t(\"syncLDAPGroupsSuccessful\", {\n result: result.status,\n }),\n );\n } catch (error) {\n addError(\"syncLDAPGroupsError\", error);\n }\n refresh();\n };\n\n const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({\n titleKey: \"deleteMappingTitle\",\n messageKey: \"deleteMappingConfirm\",\n continueButtonLabel: \"delete\",\n continueButtonVariant: ButtonVariant.danger,\n onConfirm: async () => {\n try {\n await adminClient.components.del({\n id: mapping!.id!,\n });\n addAlert(t(\"mappingDeletedSuccess\"), AlertVariant.success);\n navigate(toUserFederationLdap({ id, realm, tab: \"mappers\" }));\n } catch (error) {\n addError(\"mappingDeletedError\", error);\n }\n },\n });\n\n const mapperType = useWatch({\n control: form.control,\n name: \"providerId\",\n });\n\n if (!components) {\n return ;\n }\n\n const isNew = mapperId === \"new\";\n const mapper = components.find((c) => c.id === mapperType);\n return (\n <>\n \n \n {t(\"delete\")}\n ,\n ...(mapper?.metadata.fedToKeycloakSyncSupported\n ? [\n sync(\"fedToKeycloak\")}\n >\n {t(mapper.metadata.fedToKeycloakSyncMessage)}\n ,\n ]\n : []),\n ...(mapper?.metadata.keycloakToFedSyncSupported\n ? [\n {\n sync(\"keycloakToFed\");\n }}\n >\n {t(mapper.metadata.keycloakToFedSyncMessage)}\n ,\n ]\n : []),\n ]\n }\n />\n \n \n save(form.getValues()))}\n >\n {!isNew && }\n \n \n \n {!isNew ? (\n \n ) : (\n \n }\n fieldId=\"kc-providerId\"\n isRequired\n >\n (\n \n setIsMapperDropdownOpen(!isMapperDropdownOpen)\n }\n isOpen={isMapperDropdownOpen}\n onSelect={(value) => {\n setupForm({\n providerId: value as string,\n ...Object.fromEntries(\n components\n .find((c) => c.id === value)\n ?.properties.filter((m) => m.type === \"List\")\n .map((m) => [\n convertToName(m.name!),\n m.options?.[0],\n ]) || [],\n ),\n });\n setIsMapperDropdownOpen(false);\n }}\n selections={field.value}\n variant={SelectVariant.typeahead}\n aria-label={t(\"selectMapperType\")}\n >\n {components.map((c) => (\n \n {c.id}\n \n ))}\n \n )}\n > \n \n )}\n\n {!!mapperType && (\n \n )}\n \n \n \n \n \n \n \n >\n );\n}\n"],"names":["LdapMapperDetails","adminClient","useAdminClient","form","useForm","mapping","setMapping","useState","components","setComponents","id","mapperId","useParams","navigate","useNavigate","realm","useRealm","t","useTranslation","addAlert","addError","useAlerts","isMapperDropdownOpen","setIsMapperDropdownOpen","key","setKey","refresh","useFetch","fetchedMapper","setupForm","mapper","save","component","convertFormValuesToObject","map","result","value","toUserFederationLdap","AlertVariant","error","sync","direction","toggleDeleteDialog","DeleteConfirm","useConfirmDialog","ButtonVariant","mapperType","useWatch","KeycloakSpinner","isNew","c","jsxs","Fragment","jsx","ViewHeader","DropdownItem","PageSection","FormProvider","FormAccess","TextControl","FormGroup","HelpItem","Controller","field","KeycloakSelect","m","convertToName","SelectVariant","SelectOption","DynamicComponents","ActionGroup","Button"],"mappings":"svCAwCA,SAAwBA,IAAoB,CACpC,KAAA,CAAE,YAAAC,GAAgBC,IAElBC,EAAOC,IACP,CAACC,EAASC,CAAU,EAAIC,EAAkC,EAC1D,CAACC,EAAYC,CAAa,EAAIF,EAAwC,EAEtE,CAAE,GAAAG,EAAI,SAAAC,CAAS,EAAIC,GAA0C,EAC7DC,EAAWC,IACX,CAAE,MAAAC,GAAUC,IACZ,CAAE,EAAAC,GAAMC,IACR,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAEnC,CAACC,EAAsBC,CAAuB,EAAIhB,EAAS,EAAK,EAChE,CAACiB,EAAKC,CAAM,EAAIlB,EAAS,CAAC,EAC1BmB,EAAU,IAAMD,EAAOD,EAAM,CAAC,EAEpCG,EACE,SAAY,CACV,MAAMnB,EAAa,MAAMP,EAAY,WAAW,kBAAkB,CAChE,GAAAS,EACA,KAAM,qDAAA,CACP,EACG,GAAAC,GAAYA,IAAa,MAAO,CAClC,MAAMiB,EAAgB,MAAM3B,EAAY,WAAW,QAAQ,CACzD,GAAIU,CAAA,CACL,EACM,MAAA,CAAE,WAAAH,EAA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