Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
theme.keycloak.v2.admin.resources.assets.CreateClientRole-9847a33c.js.map Maven / Gradle / Ivy
Go to download
The user inferface to administrate the Keycloak server.
{"version":3,"file":"CreateClientRole-9847a33c.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 { SubmitHandler, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate, useParams } from \"react-router-dom\";\n\nimport { adminClient } 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 { t } = useTranslation(\"roles\");\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(\"roles:roleCreateError\", error);\n }\n };\n\n return (\n \n );\n}\n"],"names":["CreateClientRole","t","useTranslation","form","useForm","navigate","useNavigate","clientId","useParams","realm","useRealm","addAlert","addError","useAlerts","onSubmit","formValues","role","adminClient","createdRole","AlertVariant","toClientRole","error","jsx","RoleForm","toClient"],"mappings":"icAeA,SAAwBA,GAAmB,CACzC,KAAM,CAAE,EAAAC,CAAA,EAAMC,EAAe,OAAO,EAC9BC,EAAOC,EAAuB,CAAE,KAAM,UAAY,CAAA,EAClDC,EAAWC,IACX,CAAE,SAAAC,GAAaC,IACf,CAAE,MAAAC,GAAUC,IACZ,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EAEnCC,EAAyC,MAAOC,GAAe,CACnE,MAAMC,EAA2B,CAC/B,GAAGD,EACH,KAAMA,EAAW,MAAM,KAAK,EAC5B,WAAY,CAAC,CAAA,EAGX,GAAA,CACI,MAAAE,EAAY,QAAQ,WAAW,CACnC,GAAIV,EACJ,GAAGS,CAAA,CACJ,EAED,MAAME,EAAc,MAAMD,EAAY,QAAQ,SAAS,CACrD,GAAIV,EACJ,SAAUS,EAAK,IAAA,CAChB,EAEDL,EAASV,EAAE,aAAa,EAAGkB,EAAa,OAAO,EAC/Cd,EACEe,EAAa,CACX,MAAAX,EACA,SAAAF,EACA,GAAIW,EAAY,GAChB,IAAK,SAAA,CACN,CAAA,QAEIG,EAAO,CACdT,EAAS,wBAAyBS,CAAK,CACzC,CAAA,EAIA,OAAAC,EAAA,IAACC,EAAA,CACC,KAAApB,EACA,SAAAW,EACA,WAAYU,EAAS,CACnB,MAAAf,EACA,SAAAF,EACA,IAAK,OAAA,CACN,EACD,KAAK,iBACL,SAAU,EAAA,CAAA,CAGhB"}