theme.keycloak.v2.admin.resources.assets.NewRealmForm-BpA3mlwU.js.map Maven / Gradle / Ivy
{"version":3,"file":"NewRealmForm-BpA3mlwU.js","sources":["../../src/realm/add/NewRealmForm.tsx"],"sourcesContent":["import type RealmRepresentation from \"@keycloak/keycloak-admin-client/lib/defs/realmRepresentation\";\nimport { ActionGroup, Button, PageSection } from \"@patternfly/react-core\";\nimport { useState } from \"react\";\nimport { FormProvider, useForm } from \"react-hook-form\";\nimport { useTranslation } from \"react-i18next\";\nimport { useNavigate } from \"react-router-dom\";\nimport { FormSubmitButton, TextControl } from \"@keycloak/keycloak-ui-shared\";\nimport { useAdminClient } from \"../../admin-client\";\nimport { DefaultSwitchControl } from \"../../components/SwitchControl\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { FormAccess } from \"../../components/form/FormAccess\";\nimport { JsonFileUpload } from \"../../components/json-file-upload/JsonFileUpload\";\nimport { ViewHeader } from \"../../components/view-header/ViewHeader\";\nimport { useRealms } from \"../../context/RealmsContext\";\nimport { useWhoAmI } from \"../../context/whoami/WhoAmI\";\nimport { toDashboard } from \"../../dashboard/routes/Dashboard\";\nimport { convertFormValuesToObject, convertToFormValues } from \"../../util\";\n\nexport default function NewRealmForm() {\n const { adminClient } = useAdminClient();\n\n const { t } = useTranslation();\n const navigate = useNavigate();\n const { refresh, whoAmI } = useWhoAmI();\n const { refresh: refreshRealms } = useRealms();\n const { addAlert, addError } = useAlerts();\n const [realm, setRealm] = useState();\n\n const form = useForm({\n mode: \"onChange\",\n });\n\n const { handleSubmit, setValue, formState } = form;\n\n const handleFileChange = (obj?: object) => {\n const defaultRealm = { id: \"\", realm: \"\", enabled: true };\n convertToFormValues(obj || defaultRealm, setValue);\n setRealm(obj || defaultRealm);\n };\n\n const save = async (fields: RealmRepresentation) => {\n try {\n await adminClient.realms.create({\n ...realm,\n ...convertFormValuesToObject(fields),\n });\n addAlert(t(\"saveRealmSuccess\"));\n\n refresh();\n await refreshRealms();\n navigate(toDashboard({ realm: fields.realm }));\n } catch (error) {\n addError(\"saveRealmError\", error);\n }\n };\n\n return (\n <>\n \n \n \n \n \n \n \n \n \n {t(\"create\")}\n \n \n \n \n \n \n >\n );\n}\n"],"names":["NewRealmForm","adminClient","useAdminClient","t","useTranslation","navigate","useNavigate","refresh","whoAmI","useWhoAmI","refreshRealms","useRealms","addAlert","addError","useAlerts","realm","setRealm","useState","form","useForm","handleSubmit","setValue","formState","handleFileChange","obj","defaultRealm","convertToFormValues","jsxs","Fragment","jsx","ViewHeader","PageSection","FormProvider","FormAccess","fields","convertFormValuesToObject","toDashboard","error","JsonFileUpload","TextControl","DefaultSwitchControl","ActionGroup","FormSubmitButton","Button"],"mappings":"wpBAkBA,SAAwBA,IAAe,CAC/B,KAAA,CAAE,YAAAC,GAAgBC,IAElB,CAAE,EAAAC,GAAMC,IACRC,EAAWC,IACX,CAAE,QAAAC,EAAS,OAAAC,CAAO,EAAIC,EAAU,EAChC,CAAE,QAASC,CAAc,EAAIC,EAAU,EACvC,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EACnC,CAACC,EAAOC,CAAQ,EAAIC,EAA8B,EAElDC,EAAOC,EAA6B,CACxC,KAAM,UAAA,CACP,EAEK,CAAE,aAAAC,EAAc,SAAAC,EAAU,UAAAC,CAAA,EAAcJ,EAExCK,EAAoBC,GAAiB,CACzC,MAAMC,EAAe,CAAE,GAAI,GAAI,MAAO,GAAI,QAAS,IAC/BC,EAAAF,GAAOC,EAAcJ,CAAQ,EACjDL,EAASQ,GAAOC,CAAY,CAAA,EAmB9B,OAEIE,EAAAC,EAAA,CAAA,SAAA,CAAAC,EAACC,EAAW,CAAA,SAAS,cAAc,OAAO,eAAe,IACxDC,EAAY,CAAA,QAAQ,QACnB,SAACF,EAAAG,EAAA,CAAc,GAAGd,EAChB,SAAAS,EAACM,EAAA,CACC,aAAY,GACZ,SAAUb,EAvBP,MAAOc,GAAgC,CAC9C,GAAA,CACI,MAAAjC,EAAY,OAAO,OA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