theme.keycloak.v2.admin.resources.assets.CreateRealmRole-CrEMetD9.js.map Maven / Gradle / Ivy
{"version":3,"file":"CreateRealmRole-CrEMetD9.js","sources":["../../src/realm-roles/CreateRealmRole.tsx"],"sourcesContent":["import type RoleRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/roleRepresentation\";\nimport { AlertVariant } from \"@patternfly/react-core\";\nimport { FormProvider, SubmitHandler, useForm } 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 { AttributeForm } from \"../components/key-value-form/AttributeForm\";\nimport { RoleForm } from \"../components/role-form/RoleForm\";\nimport { useRealm } from \"../context/realm-context/RealmContext\";\nimport { toRealmRole } from \"./routes/RealmRole\";\nimport { toRealmRoles } from \"./routes/RealmRoles\";\n\nexport default function CreateRealmRole() {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const form = useForm({ mode: \"onChange\" });\n const navigate = useNavigate();\n const { realm } = useRealm();\n const { addAlert, addError } = useAlerts();\n\n const onSubmit: SubmitHandler = async (formValues) => {\n const role: RoleRepresentation = {\n ...formValues,\n name: formValues.name?.trim(),\n attributes: {},\n };\n\n try {\n await adminClient.roles.create(role);\n\n const createdRole = await adminClient.roles.findOneByName({\n name: formValues.name!,\n });\n\n if (!createdRole) {\n throw new Error(t(\"notFound\"));\n }\n\n addAlert(t(\"roleCreated\"), AlertVariant.success);\n navigate(toRealmRole({ realm, id: createdRole.id!, tab: \"details\" }));\n } catch (error) {\n addError(\"roleCreateError\", error);\n }\n };\n\n return (\n \n \n \n );\n}\n"],"names":["CreateRealmRole","adminClient","useAdminClient","useTranslation","form","useForm","navigate","useNavigate","realm","useRealm","addAlert","addError","useAlerts","jsx","FormProvider","RoleForm","formValues","role","createdRole","AlertVariant","toRealmRole","error","toRealmRoles"],"mappings":"6TAaA,SAAwBA,GAAkB,CAClC,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,GAAMC,IACRC,EAAOC,EAAuB,CAAE,KAAM,UAAY,CAAA,EAClDC,EAAWC,IACX,CAAE,MAAAC,GAAUC,IACZ,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EA4BvC,OAAAC,EAACC,EAAc,CAAA,GAAGV,EAChB,SAAAS,EAACE,EAAA,CACC,KAAAX,EACA,SA7ByC,MAAOY,GAAe,CACnE,MAAMC,EAA2B,CAC/B,GAAGD,EACH,KAAMA,EAAW,MAAM,KAAK,EAC5B,WAAY,CAAC,CAAA,EAGX,GAAA,CACI,MAAAf,EAAY,MAAM,OAAOgB,CAAI,EAEnC,MAAMC,EAAc,MAAMjB,EAAY,MAAM,cAAc,CACxD,KAAMe,EAAW,IAAA,CAClB,EAED,GAAI,CAACE,EACH,MAAM,IAAI,MAAM,EAAE,UAAU,CAAC,EAG/BR,EAAS,EAAE,aAAa,EAAGS,EAAa,OAAO,EACtCb,EAAAc,EAAY,CAAE,MAAAZ,EAAO,GAAIU,EAAY,GAAK,IAAK,SAAW,CAAA,CAAC,QAC7DG,EAAO,CACdV,EAAS,kBAAmBU,CAAK,CACnC,CAAA,EAQI,WAAYC,EAAa,CAAE,MAAAd,EAAO,EAClC,KAAK,eACL,SAAU,EAAA,CAEd,CAAA,CAAA,CAEJ"}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy