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

theme.keycloak.v2.admin.resources.assets.MappingDetails-FsZeCvYK.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"MappingDetails-FsZeCvYK.js","sources":["../../src/client-scopes/details/MappingDetails.tsx"],"sourcesContent":["import type ProtocolMapperRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/protocolMapperRepresentation\";\nimport type { ProtocolMapperTypeRepresentation } from \"@keycloak/keycloak-admin-client/lib/defs/serverInfoRepesentation\";\nimport {\n  ActionGroup,\n  AlertVariant,\n  Button,\n  ButtonVariant,\n  DropdownItem,\n  FormGroup,\n  PageSection,\n  TextInput,\n} from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link, useMatch, useNavigate } from \"react-router-dom\";\nimport { TextControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { toDedicatedScope } from \"../../clients/routes/DedicatedScopeDetails\";\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 { ViewHeader } from \"../../components/view-header/ViewHeader\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { useServerInfo } from \"../../context/server-info/ServerInfoProvider\";\nimport { convertFormValuesToObject, convertToFormValues } from \"../../util\";\nimport { useFetch } from \"../../utils/useFetch\";\nimport { useParams } from \"../../utils/useParams\";\nimport { toClientScope } from \"../routes/ClientScope\";\nimport { MapperParams, MapperRoute } from \"../routes/Mapper\";\n\nexport default function MappingDetails() {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const { addAlert, addError } = useAlerts();\n\n  const { id, mapperId } = useParams();\n  const form = useForm();\n  const { setValue, handleSubmit } = form;\n  const [mapping, setMapping] = useState();\n  const [config, setConfig] = useState<{\n    protocol?: string;\n    protocolMapper?: string;\n  }>();\n\n  const navigate = useNavigate();\n  const { realm } = useRealm();\n  const serverInfo = useServerInfo();\n  const isGuid = /^[{]?[0-9a-fA-F]{8}-([0-9a-fA-F]{4}-){3}[0-9a-fA-F]{12}[}]?$/;\n  const isUpdating = !!mapperId.match(isGuid);\n\n  const isOnClientScope = !!useMatch(MapperRoute.path);\n  const toDetails = () =>\n    isOnClientScope\n      ? toClientScope({ realm, id, tab: \"mappers\" })\n      : toDedicatedScope({ realm, clientId: id, tab: \"mappers\" });\n\n  useFetch(\n    async () => {\n      let data: ProtocolMapperRepresentation | undefined;\n      if (isUpdating) {\n        if (isOnClientScope) {\n          data = await adminClient.clientScopes.findProtocolMapper({\n            id,\n            mapperId,\n          });\n        } else {\n          data = await adminClient.clients.findProtocolMapperById({\n            id,\n            mapperId,\n          });\n        }\n        if (!data) {\n          throw new Error(t(\"notFound\"));\n        }\n\n        const mapperTypes = serverInfo.protocolMapperTypes![data!.protocol!];\n        const mapping = mapperTypes.find(\n          (type) => type.id === data!.protocolMapper,\n        );\n\n        return {\n          config: {\n            protocol: data.protocol,\n            protocolMapper: data.protocolMapper,\n          },\n          mapping,\n          data,\n        };\n      } else {\n        const model = isOnClientScope\n          ? await adminClient.clientScopes.findOne({ id })\n          : await adminClient.clients.findOne({ id });\n        if (!model) {\n          throw new Error(t(\"notFound\"));\n        }\n        const protocolMappers =\n          serverInfo.protocolMapperTypes![model.protocol!];\n        const mapping = protocolMappers.find(\n          (mapper) => mapper.id === mapperId,\n        );\n        if (!mapping) {\n          throw new Error(t(\"notFound\"));\n        }\n        return {\n          mapping,\n          config: {\n            protocol: model.protocol,\n            protocolMapper: mapperId,\n          },\n        };\n      }\n    },\n    ({ config, mapping, data }) => {\n      setConfig(config);\n      setMapping(mapping);\n      if (data) {\n        convertToFormValues(data, setValue);\n      }\n    },\n    [],\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        if (isOnClientScope) {\n          await adminClient.clientScopes.delProtocolMapper({\n            id,\n            mapperId,\n          });\n        } else {\n          await adminClient.clients.delProtocolMapper({\n            id,\n            mapperId,\n          });\n        }\n        addAlert(t(\"mappingDeletedSuccess\"), AlertVariant.success);\n        navigate(toDetails());\n      } catch (error) {\n        addError(\"mappingDeletedError\", error);\n      }\n    },\n  });\n\n  const save = async (formMapping: ProtocolMapperRepresentation) => {\n    const key = isUpdating ? \"Updated\" : \"Created\";\n    try {\n      const mapping = { ...config, ...convertFormValuesToObject(formMapping) };\n      if (isUpdating) {\n        isOnClientScope\n          ? await adminClient.clientScopes.updateProtocolMapper(\n              { id, mapperId },\n              { id: mapperId, ...mapping },\n            )\n          : await adminClient.clients.updateProtocolMapper(\n              { id, mapperId },\n              { id: mapperId, ...mapping },\n            );\n      } else {\n        isOnClientScope\n          ? await adminClient.clientScopes.addProtocolMapper({ id }, mapping)\n          : await adminClient.clients.addProtocolMapper({ id }, mapping);\n      }\n      addAlert(t(`mapping${key}Success`), AlertVariant.success);\n    } catch (error) {\n      addError(`mapping${key}Error`, error);\n    }\n  };\n\n  return (\n    <>\n      \n      \n                  {t(\"delete\")}\n                ,\n              ]\n            : undefined\n        }\n      />\n      \n        \n          \n            \n              \n            \n            \n            \n            \n              \n               }\n              >\n                {t(\"cancel\")}\n              \n            \n          \n        \n      \n    \n  );\n}\n"],"names":["MappingDetails","adminClient","useAdminClient","t","useTranslation","addAlert","addError","useAlerts","id","mapperId","useParams","form","useForm","setValue","handleSubmit","mapping","setMapping","useState","config","setConfig","navigate","useNavigate","realm","useRealm","serverInfo","useServerInfo","isGuid","isUpdating","isOnClientScope","useMatch","MapperRoute","toDetails","toClientScope","toDedicatedScope","useFetch","data","type","model","mapper","convertToFormValues","toggleDeleteDialog","DeleteConfirm","useConfirmDialog","ButtonVariant","AlertVariant","error","save","formMapping","key","convertFormValuesToObject","jsxs","Fragment","jsx","ViewHeader","DropdownItem","PageSection","FormProvider","FormAccess","FormGroup","TextInput","TextControl","DynamicComponents","ActionGroup","Button","props","Link"],"mappings":"suCAgCA,SAAwBA,IAAiB,CACjC,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACR,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAEnC,CAAE,GAAAC,EAAI,SAAAC,CAAS,EAAIC,GAAwB,EAC3CC,EAAOC,IACP,CAAE,SAAAC,EAAU,aAAAC,CAAiB,EAAAH,EAC7B,CAACI,EAASC,CAAU,EAAIC,EAA2C,EACnE,CAACC,EAAQC,CAAS,EAAIF,EAGzB,EAEGG,EAAWC,IACX,CAAE,MAAAC,GAAUC,IACZC,EAAaC,IACbC,EAAS,+DACTC,EAAa,CAAC,CAAClB,EAAS,MAAMiB,CAAM,EAEpCE,EAAkB,CAAC,CAACC,EAASC,EAAY,IAAI,EAC7CC,EAAY,IAChBH,EACII,EAAc,CAAE,MAAAV,EAAO,GAAAd,EAAI,IAAK,SAAW,CAAA,EAC3CyB,GAAiB,CAAE,MAAAX,EAAO,SAAUd,EAAI,IAAK,UAAW,EAE9D0B,EACE,SAAY,CACN,IAAAC,EACJ,GAAIR,EAAY,CAYd,GAXIC,EACKO,EAAA,MAAMlC,EAAY,aAAa,mBAAmB,CACvD,GAAAO,EACA,SAAAC,CAAA,CACD,EAEM0B,EAAA,MAAMlC,EAAY,QAAQ,uBAAuB,CACtD,GAAAO,EACA,SAAAC,CAAA,CACD,EAEC,CAAC0B,EACH,MAAM,IAAI,MAAMhC,EAAE,UAAU,CAAC,EAI/B,MAAMY,EADcS,EAAW,oBAAqBW,EAAM,QAAS,EACvC,KACzBC,GAASA,EAAK,KAAOD,EAAM,cAAA,EAGvB,MAAA,CACL,OAAQ,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