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

theme.keycloak.v2.admin.resources.assets.KeyProviderForm-BJnAxavo.js.map Maven / Gradle / Ivy

There is a newer version: 26.0.7
Show newest version
{"version":3,"file":"KeyProviderForm-BJnAxavo.js","sources":["../../src/realm-settings/keys/key-providers/KeyProviderForm.tsx"],"sourcesContent":["import type ComponentRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/componentRepresentation\";\nimport {\n  ActionGroup,\n  AlertVariant,\n  Button,\n  PageSection,\n} from \"@patternfly/react-core\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate } from \"react-router-dom\";\nimport { TextControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../../admin-client\";\nimport { useAlerts } from \"../../../components/alert/Alerts\";\nimport { DynamicComponents } from \"../../../components/dynamic/DynamicComponents\";\nimport { FormAccess } from \"../../../components/form/FormAccess\";\nimport { ViewHeader } from \"../../../components/view-header/ViewHeader\";\nimport { useServerInfo } from \"../../../context/server-info/ServerInfoProvider\";\nimport { KEY_PROVIDER_TYPE } from \"../../../util\";\nimport { useFetch } from \"../../../utils/useFetch\";\nimport { useParams } from \"../../../utils/useParams\";\nimport { KeyProviderParams, ProviderType } from \"../../routes/KeyProvider\";\nimport { toKeysTab } from \"../../routes/KeysTab\";\n\ntype KeyProviderFormProps = {\n  id?: string;\n  providerType: ProviderType;\n  onClose?: () => void;\n};\n\nexport const KeyProviderForm = ({\n  providerType,\n  onClose,\n}: KeyProviderFormProps) => {\n  const { adminClient } = useAdminClient();\n\n  const { t } = useTranslation();\n  const { id } = useParams<{ id: string }>();\n  const { addAlert, addError } = useAlerts();\n\n  const serverInfo = useServerInfo();\n  const allComponentTypes =\n    serverInfo.componentTypes?.[KEY_PROVIDER_TYPE] ?? [];\n\n  const form = useForm({\n    mode: \"onChange\",\n  });\n  const { handleSubmit, reset } = form;\n\n  const save = async (component: ComponentRepresentation) => {\n    if (component.config)\n      Object.entries(component.config).forEach(\n        ([key, value]) =>\n          (component.config![key] = Array.isArray(value) ? value : [value]),\n      );\n    try {\n      if (id) {\n        await adminClient.components.update(\n          { id },\n          {\n            ...component,\n            providerType: KEY_PROVIDER_TYPE,\n          },\n        );\n        addAlert(t(\"saveProviderSuccess\"), AlertVariant.success);\n      } else {\n        await adminClient.components.create({\n          ...component,\n          providerId: providerType,\n          providerType: KEY_PROVIDER_TYPE,\n        });\n        addAlert(t(\"saveProviderSuccess\"), AlertVariant.success);\n        onClose?.();\n      }\n    } catch (error) {\n      addError(\"saveProviderError\", error);\n    }\n  };\n\n  useFetch(\n    async () => {\n      if (id) return await adminClient.components.findOne({ id });\n    },\n    (result) => {\n      if (result) {\n        reset({ ...result });\n      }\n    },\n    [],\n  );\n\n  return (\n    \n      \n        {id && (\n          \n        )}\n        \n         type.id === providerType)\n              ?.properties || []\n          }\n        />\n        \n          \n            {t(\"save\")}\n          \n          \n        \n      \n    \n  );\n};\n\nexport default function KeyProviderFormPage() {\n  const { t } = useTranslation();\n  const params = useParams();\n  const navigate = useNavigate();\n\n  return (\n    <>\n      \n      \n        \n            navigate(toKeysTab({ realm: params.realm, tab: \"providers\" }))\n          }\n        />\n      \n    \n  );\n}\n"],"names":["KeyProviderForm","providerType","onClose","adminClient","useAdminClient","t","useTranslation","id","useParams","addAlert","addError","useAlerts","allComponentTypes","useServerInfo","KEY_PROVIDER_TYPE","form","useForm","handleSubmit","reset","save","component","key","value","AlertVariant","error","useFetch","result","jsx","FormAccess","jsxs","FormProvider","TextControl","DynamicComponents","type","ActionGroup","Button","KeyProviderFormPage","params","navigate","useNavigate","Fragment","ViewHeader","PageSection","toKeysTab"],"mappings":"qnCA6BO,MAAMA,EAAkB,CAAC,CAC9B,aAAAC,EACA,QAAAC,CACF,IAA4B,CACpB,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACR,CAAE,GAAAC,GAAOC,IACT,CAAE,SAAAC,EAAU,S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