theme.keycloak.v2.admin.resources.assets.CreateClientRole-DxXSRVTy.js.map Maven / Gradle / Ivy
{"version":3,"file":"CreateClientRole-DxXSRVTy.js","sources":["../../src/clients/roles/CreateClientRole.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, useParams } 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 { toClient } from \"../routes/Client\";\nimport { toClientRole } from \"../routes/ClientRole\";\nimport { NewRoleParams } from \"../routes/NewRole\";\n\nexport default function CreateClientRole() {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const form = useForm({ mode: \"onChange\" });\n const navigate = useNavigate();\n const { clientId } = useParams();\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.clients.createRole({\n id: clientId,\n ...role,\n });\n\n const createdRole = (await adminClient.clients.findRole({\n id: clientId!,\n roleName: role.name!,\n }))!;\n\n addAlert(t(\"roleCreated\"), AlertVariant.success);\n navigate(\n toClientRole({\n realm,\n clientId: clientId!,\n id: createdRole.id!,\n tab: \"details\",\n }),\n );\n } catch (error) {\n addError(\"roleCreateError\", error);\n }\n };\n\n return (\n \n \n \n );\n}\n"],"names":["CreateClientRole","adminClient","useAdminClient","t","useTranslation","form","useForm","navigate","useNavigate","clientId","useParams","realm","useRealm","addAlert","addError","useAlerts","jsx","FormProvider","RoleForm","formValues","role","createdRole","AlertVariant","toClientRole","error","toClient"],"mappings":"gUAcA,SAAwBA,GAAmB,CACnC,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACRC,EAAOC,EAAuB,CAAE,KAAM,UAAY,CAAA,EAClDC,EAAWC,IACX,CAAE,SAAAC,GAAaC,IACf,CAAE,MAAAC,GAAUC,IACZ,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAmCvC,OAAAC,EAACC,EAAc,CAAA,GAAGZ,EAChB,SAAAW,EAACE,EAAA,CACC,KAAAb,EACA,SApCyC,MAAOc,GAAe,CACnE,MAAMC,EAA2B,CAC/B,GAAGD,EACH,KAAMA,EAAW,MAAM,KAAK,EAC5B,WAAY,CAAC,CAAA,EAGX,GAAA,CACI,MAAAlB,EAAY,QAAQ,WAAW,CACnC,GAAIQ,EACJ,GAAGW,CAAA,CACJ,EAED,MAAMC,EAAe,MAAMpB,EAAY,QAAQ,SAAS,CACtD,GAAIQ,EACJ,SAAUW,EAAK,IAAA,CAChB,EAEDP,EAASV,EAAE,aAAa,EAAGmB,EAAa,OAAO,EAC/Cf,EACEgB,EAAa,CACX,MAAAZ,EACA,SAAAF,EACA,GAAIY,EAAY,GAChB,IAAK,SAAA,CACN,CAAA,QAEIG,EAAO,CACdV,EAAS,kBAAmBU,CAAK,CACnC,CAAA,EAQI,WAAYC,EAAS,CACnB,MAAAd,EACA,SAAAF,EACA,IAAK,OAAA,CACN,EACD,KAAK,iBACL,SAAU,EAAA,CAEd,CAAA,CAAA,CAEJ"}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy