All Downloads are FREE. Search and download functionalities are using the official Maven repository.

theme.keycloak.v2.admin.resources.assets.AddMapper-C3Bbsam6.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"AddMapper-C3Bbsam6.js","sources":["../../src/identity-providers/add/AddMapperForm.tsx","../../src/identity-providers/add/AddMapper.tsx"],"sourcesContent":["import type IdentityProviderMapperRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperRepresentation\";\nimport type { IdentityProviderMapperTypeRepresentation } from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperTypeRepresentation\";\nimport {\n  HelpItem,\n  KeycloakSelect,\n  SelectControl,\n  SelectVariant,\n  TextControl,\n} from \"@keycloak/keycloak-ui-shared\";\nimport { FormGroup, SelectOption } from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { Controller, UseFormReturn } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport type { IdPMapperRepresentationWithAttributes } from \"./AddMapper\";\n\ntype AddMapperFormProps = {\n  mapperTypes: IdentityProviderMapperRepresentation[];\n  mapperType: IdentityProviderMapperTypeRepresentation;\n  id: string;\n  updateMapperType: (\n    mapperType: IdentityProviderMapperTypeRepresentation,\n  ) => void;\n  form: UseFormReturn;\n};\n\nexport const AddMapperForm = ({\n  mapperTypes,\n  mapperType,\n  form,\n  id,\n  updateMapperType,\n}: AddMapperFormProps) => {\n  const { t } = useTranslation();\n\n  const { control } = form;\n\n  const [mapperTypeOpen, setMapperTypeOpen] = useState(false);\n\n  const syncModes = [\"inherit\", \"import\", \"legacy\", \"force\"];\n\n  return (\n    <>\n      \n       ({\n          key: option.toUpperCase(),\n          value: t(`syncModes.${option}`),\n        }))}\n        controller={{ defaultValue: syncModes[0].toUpperCase() }}\n      />\n      \n        }\n        fieldId=\"identityProviderMapper\"\n      >\n         (\n             setMapperTypeOpen(!mapperTypeOpen)}\n              onSelect={(value) => {\n                const mapperType =\n                  value as IdentityProviderMapperTypeRepresentation;\n                updateMapperType(mapperType);\n                field.onChange(mapperType.id);\n                setMapperTypeOpen(false);\n              }}\n              selections={mapperType.name}\n              variant={SelectVariant.single}\n              aria-label={t(\"mapperType\")}\n              isOpen={mapperTypeOpen}\n            >\n              {mapperTypes.map((option) => (\n                \n                  {option.name}\n                \n              ))}\n            \n          )}\n        />\n      \n    \n  );\n};\n","import type IdentityProviderMapperRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperRepresentation\";\nimport type { IdentityProviderMapperTypeRepresentation } from \"@keycloak/keycloak-admin-client/lib/defs/identityProviderMapperTypeRepresentation\";\nimport type RoleRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/roleRepresentation\";\nimport {\n  ActionGroup,\n  AlertVariant,\n  Button,\n  ButtonVariant,\n  DropdownItem,\n  PageSection,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, useNavigate } from \"react-router-dom\";\nimport { TextControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { useConfirmDialog } from \"../../components/confirm-dialog/ConfirmDialog\";\nimport { DynamicComponents } from \"../../components/dynamic/DynamicComponents\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport type { AttributeForm } from \"../../components/key-value-form/AttributeForm\";\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 useLocaleSort, { mapByKey } from \"../../utils/useLocaleSort\";\nimport { useParams } from \"../../utils/useParams\";\nimport {\n  IdentityProviderEditMapperParams,\n  toIdentityProviderEditMapper,\n} from \"../routes/EditMapper\";\nimport { toIdentityProvider } from \"../routes/IdentityProvider\";\nimport { AddMapperForm } from \"./AddMapperForm\";\n\nexport type IdPMapperRepresentationWithAttributes =\n  IdentityProviderMapperRepresentation & AttributeForm;\n\nexport type Role = RoleRepresentation & {\n  clientId?: string;\n};\n\nexport default function AddMapper() {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n\n  const form = useForm({\n    shouldUnregister: true,\n  });\n  const { handleSubmit } = form;\n  const { addAlert, addError } = useAlerts();\n  const navigate = useNavigate();\n  const localeSort = useLocaleSort();\n\n  const { realm } = useRealm();\n\n  const { id, providerId, alias } =\n    useParams();\n\n  const [mapperTypes, setMapperTypes] =\n    useState();\n\n  const [currentMapper, setCurrentMapper] =\n    useState();\n\n  const save = async (idpMapper: IdentityProviderMapperRepresentation) => {\n    const mapper = convertFormValuesToObject(idpMapper);\n\n    const identityProviderMapper = {\n      ...mapper,\n      config: {\n        ...mapper.config,\n      },\n      identityProviderAlias: alias!,\n    };\n\n    if (id) {\n      try {\n        await adminClient.identityProviders.updateMapper(\n          {\n            id: id!,\n            alias: alias!,\n          },\n          { ...identityProviderMapper, id },\n        );\n        addAlert(t(\"mapperSaveSuccess\"), AlertVariant.success);\n      } catch (error) {\n        addError(t(\"mapperSaveError\"), error);\n      }\n    } else {\n      try {\n        const createdMapper = await adminClient.identityProviders.createMapper({\n          identityProviderMapper,\n          alias: alias!,\n        });\n\n        addAlert(t(\"mapperCreateSuccess\"), AlertVariant.success);\n        navigate(\n          toIdentityProviderEditMapper({\n            realm,\n            alias,\n            providerId: providerId,\n            id: createdMapper.id,\n          }),\n        );\n      } catch (error) {\n        addError(t(\"mapperCreateError\"), error);\n      }\n    }\n  };\n\n  const [toggleDeleteMapperDialog, DeleteMapperConfirm] = useConfirmDialog({\n    titleKey: \"deleteProviderMapper\",\n    messageKey: t(\"deleteMapperConfirm\", {\n      mapper: currentMapper?.name,\n    }),\n    continueButtonLabel: \"delete\",\n    continueButtonVariant: ButtonVariant.danger,\n    onConfirm: async () => {\n      try {\n        await adminClient.identityProviders.delMapper({\n          alias: alias,\n          id: id!,\n        });\n        addAlert(t(\"deleteMapperSuccess\"), AlertVariant.success);\n        navigate(\n          toIdentityProvider({ providerId, alias, tab: \"mappers\", realm }),\n        );\n      } catch (error) {\n        addError(\"deleteErrorIdentityProvider\", error);\n      }\n    },\n  });\n\n  useFetch(\n    () =>\n      Promise.all([\n        id ? adminClient.identityProviders.findOneMapper({ alias, id }) : null,\n        adminClient.identityProviders.findMapperTypes({ alias }),\n      ]),\n    ([mapper, mapperTypes]) => {\n      const mappers = localeSort(Object.values(mapperTypes), mapByKey(\"name\"));\n      if (mapper) {\n        setCurrentMapper(\n          mappers.find(({ id }) => id === mapper.identityProviderMapper),\n        );\n        setupForm(mapper);\n      } else {\n        setCurrentMapper(mappers[0]);\n      }\n\n      setMapperTypes(mappers);\n    },\n    [id],\n  );\n\n  const setupForm = (mapper: IdentityProviderMapperRepresentation) => {\n    convertToFormValues(mapper, form.setValue);\n  };\n\n  if (!mapperTypes || !currentMapper) {\n    return ;\n  }\n\n  return (\n    \n      \n      \n                  {t(\"delete\")}\n                ,\n              ]\n            : undefined\n        }\n        divider\n      />\n      \n        \n          {id && (\n            \n          )}\n          {currentMapper.properties && (\n            <>\n              \n\n              \n            \n          )}\n        \n        \n          \n            {t(\"save\")}\n          \n           (\n              \n            )}\n          >\n            {t(\"cancel\")}\n          \n        \n      \n    \n  );\n}\n"],"names":["AddMapperForm","mapperTypes","mapperType","form","id","updateMapperType","t","useTranslation","control","mapperTypeOpen","setMapperTypeOpen","useState","syncModes","jsxs","Fragment","jsx","TextControl","SelectControl","option","FormGroup","HelpItem","Controller","field","KeycloakSelect","value","SelectVariant","SelectOption","AddMapper","adminClient","useAdminClient","useForm","handleSubmit","addAlert","addError","useAlerts","navigate","useNavigate","localeSort","useLocaleSort","realm","useRealm","providerId","alias","useParams","setMapperTypes","currentMapper","setCurrentMapper","save","idpMapper","mapper","convertFormValuesToObject","identityProviderMapper","AlertVariant","error","createdMapper","toIdentityProviderEditMapper","toggleDeleteMapperDialog","DeleteMapperConfirm","useConfirmDialog","ButtonVariant","toIdentityProvider","useFetch","mappers","mapByKey","setupForm","convertToFormValues","KeycloakSpinner","PageSection","ViewHeader","DropdownItem","FormAccess","FormProvider","DynamicComponents","ActionGroup","Button","props","Link"],"mappings":"4wCAyBO,MAAMA,GAAgB,CAAC,CAC5B,YAAAC,EACA,WAAAC,EACA,KAAAC,EACA,GAAAC,EACA,iBAAAC,CACF,IAA0B,CAClB,KAAA,CAAE,EAAAC,GAAMC,IAER,CAAE,QAAAC,CAAY,EAAAL,EAEd,CAACM,EAAgBC,CAAiB,EAAIC,EAAS,EAAK,EAEpDC,EAAY,CAAC,UAAW,SAAU,SAAU,OAAO,EAEzD,OAEIC,EAAAC,EAAA,CAAA,SAAA,CAAAC,EAACC,EAAA,CACC,KAAK,OACL,MAAOV,EAAE,MAAM,EACf,UAAWA,EAAE,sBAAsB,EACnC,SAAU,CAAC,CAACF,EACZ,MAAO,CACL,SAAUE,EAAE,UAAU,CACxB,CAAA,CACF,EACAS,EAACE,EAAA,CACC,KAAK,kBACL,MAAOX,EAAE,kBAAkB,EAC3B,UAAWA,EAAE,sBAAsB,EACnC,QAASM,EAAU,IAAKM,IAAY,CAClC,IAAKA,EAAO,YAAY,EACxB,MAAOZ,EAAE,aAAaY,CAAM,EAAE,CAAA,EAC9B,EACF,WAAY,CAAE,aAAcN,EAAU,CAAC,EAAE,aAAc,CAAA,CACzD,EACAG,EAACI,EAAA,CACC,MAAOb,EAAE,YAAY,EACrB,UACGS,EAAAK,EAAA,CAAS,SAAUlB,EAAW,SAAU,aAAa,aAAa,EAErE,QAAQ,yBAER,SAAAa,EAACM,EAAA,CACC,KAAK,yBACL,aAAcpB,EAAY,CAAC,EAAE,GAC7B,QAAAO,EACA,OAAQ,CAAC,CAAE,MAAAc,CAAA,IACTP,EAACQ,EAAA,CACC,SAAS,yBACT,cAAY,oBACZ,WAAY,CAAC,CAACnB,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