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

theme.keycloak.v2.admin.resources.assets.PageHandler-P2CRgucq.js.map Maven / Gradle / Ivy

{"version":3,"file":"PageHandler-P2CRgucq.js","sources":["../../src/page/PageHandler.tsx"],"sourcesContent":["import ComponentRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/componentRepresentation\";\nimport ComponentTypeRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/componentTypeRepresentation\";\nimport { ActionGroup, Button, Form, PageSection } from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { Link } from \"react-router-dom\";\nimport { useAdminClient } from \"../admin-client\";\nimport { useAlerts } from \"../components/alert/Alerts\";\nimport { DynamicComponents } from \"../components/dynamic/DynamicComponents\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport { useFetch } from \"../utils/useFetch\";\nimport { useParams } from \"../utils/useParams\";\nimport { PAGE_PROVIDER, TAB_PROVIDER } from \"./PageList\";\nimport { toPage } from \"./routes\";\n\ntype PageHandlerProps = {\n  id?: string;\n  providerType: typeof TAB_PROVIDER | typeof PAGE_PROVIDER;\n  page: ComponentTypeRepresentation;\n};\n\nexport const PageHandler = ({\n  id: idAttribute,\n  providerType,\n  page: { id: providerId, ...page },\n}: PageHandlerProps) => {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const form = useForm();\n  const { realm: realmName, realmRepresentation: realm } = useRealm();\n  const { addAlert, addError } = useAlerts();\n  const [id, setId] = useState(idAttribute);\n  const params = useParams();\n\n  useFetch(\n    async () =>\n      await Promise.all([\n        id ? adminClient.components.findOne({ id }) : Promise.resolve(),\n        providerType === TAB_PROVIDER\n          ? adminClient.components.find({ type: TAB_PROVIDER })\n          : Promise.resolve(),\n      ]),\n    ([data, tabs]) => {\n      const tab = (tabs || []).find((t) => t.providerId === providerId);\n      form.reset(data || tab || {});\n      if (tab) setId(tab.id);\n    },\n    [],\n  );\n\n  const onSubmit = async (component: ComponentRepresentation) => {\n    if (component.config || params) {\n      component.config = Object.assign(component.config || {}, params);\n      Object.entries(component.config).forEach(\n        ([key, value]) =>\n          (component.config![key] = Array.isArray(value) ? value : [value]),\n      );\n    }\n    try {\n      const updatedComponent = {\n        ...component,\n        providerId,\n        providerType,\n        parentId: realm?.id,\n      };\n      if (id) {\n        await adminClient.components.update({ id }, updatedComponent);\n      } else {\n        await adminClient.components.create(updatedComponent);\n      }\n      addAlert(\"itemSaveSuccessful\");\n    } catch (error) {\n      addError(\"itemSaveError\", error);\n    }\n  };\n\n  return (\n    \n      \n        \n          \n        \n\n        \n          \n           (\n              \n            )}\n          >\n            {t(\"cancel\")}\n          \n        \n      \n    \n  );\n};\n"],"names":["PageHandler","idAttribute","providerType","providerId","page","adminClient","useAdminClient","t","useTranslation","form","useForm","realmName","realm","useRealm","addAlert","addError","useAlerts","id","setId","useState","params","useParams","useFetch","TAB_PROVIDER","data","tabs","tab","onSubmit","component","key","value","updatedComponent","error","jsx","PageSection","jsxs","Form","FormProvider","DynamicComponents","ActionGroup","Button","props","Link","toPage"],"mappings":"oWAsBO,MAAMA,EAAc,CAAC,CAC1B,GAAIC,EACJ,aAAAC,EACA,KAAM,CAAE,GAAIC,EAAY,GAAGC,CAAK,CAClC,IAAwB,CAChB,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACRC,EAAOC,IACP,CAAE,MAAOC,EAAW,oBAAqBC,CAAA,EAAUC,IACnD,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EACnC,CAACC,EAAIC,CAAK,EAAIC,EAASlB,CAAW,EAClCmB,EAASC,IAEfC,EACE,SACE,MAAM,QAAQ,IAAI,CAChBL,EAAKZ,EAAY,WAAW,QAAQ,CAAE,GAAAY,EAAI,EAAI,QAAQ,QAAQ,EAC9Df,IAAiBqB,EACblB,EAAY,WAAW,KAAK,CAAE,KAAMkB,CAAc,CAAA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