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.UserProfileContext-2c96f79e.js.map Maven / Gradle / Ivy
Go to download
The user inferface to administrate the Keycloak server.
{"version":3,"file":"UserProfileContext-2c96f79e.js","sources":["../../src/realm-settings/user-profile/UserProfileContext.tsx"],"sourcesContent":["import type UserProfileConfig from \"@keycloak/keycloak-admin-client/lib/defs/userProfileConfig\";\nimport { AlertVariant } from \"@patternfly/react-core\";\nimport { PropsWithChildren, useState } from \"react\";\nimport { useTranslation } from \"react-i18next\";\nimport { createNamedContext, useRequiredContext } from \"ui-shared\";\n\nimport { adminClient } from \"../../admin-client\";\nimport { useAlerts } from \"../../components/alert/Alerts\";\nimport { useRealm } from \"../../context/realm-context/RealmContext\";\nimport { useFetch } from \"../../utils/useFetch\";\n\ntype UserProfileProps = {\n config: UserProfileConfig | null;\n save: SaveCallback;\n isSaving: boolean;\n};\n\nexport type SaveCallback = (\n updatedConfig: UserProfileConfig,\n options?: SaveOptions\n) => Promise;\n\nexport type SaveOptions = {\n successMessageKey?: string;\n errorMessageKey?: string;\n};\n\nexport const UserProfileContext = createNamedContext<\n UserProfileProps | undefined\n>(\"UserProfileContext\", undefined);\n\nexport const UserProfileProvider = ({ children }: PropsWithChildren) => {\n const { realm } = useRealm();\n const { addAlert, addError } = useAlerts();\n const { t } = useTranslation();\n const [config, setConfig] = useState(null);\n const [refreshCount, setRefreshCount] = useState(0);\n const [isSaving, setIsSaving] = useState(false);\n\n useFetch(\n () => adminClient.users.getProfile({ realm }),\n (config) => setConfig(config),\n [refreshCount]\n );\n\n const save: SaveCallback = async (updatedConfig, options) => {\n setIsSaving(true);\n\n try {\n await adminClient.users.updateProfile({\n ...updatedConfig,\n realm,\n });\n\n setIsSaving(false);\n setRefreshCount(refreshCount + 1);\n addAlert(\n t(options?.successMessageKey ?? \"realm-settings:userProfileSuccess\"),\n AlertVariant.success\n );\n\n return true;\n } catch (error) {\n setIsSaving(false);\n addError(\n options?.errorMessageKey ?? \"realm-settings:userProfileError\",\n error\n );\n\n return false;\n }\n };\n\n return (\n \n {children}\n \n );\n};\n\nexport const useUserProfile = () => useRequiredContext(UserProfileContext);\n"],"names":["UserProfileContext","createNamedContext","UserProfileProvider","children","realm","useRealm","addAlert","addError","useAlerts","t","useTranslation","config","setConfig","useState","refreshCount","setRefreshCount","isSaving","setIsSaving","useFetch","adminClient","save","updatedConfig","options","AlertVariant","error","jsx","useUserProfile","useRequiredContext"],"mappings":"+FA2Ba,MAAAA,EAAqBC,EAEhC,qBAAsB,MAAS,EAEpBC,EAAsB,CAAC,CAAE,SAAAC,KAAkC,CAChE,KAAA,CAAE,MAAAC,GAAUC,IACZ,CAAE,SAAAC,EAAU,SAAAC,CAAS,EAAIC,EAAU,EACnC,CAAE,EAAAC,GAAMC,IACR,CAACC,EAAQC,CAAS,EAAIC,WAAmC,IAAI,EAC7D,CAACC,EAAcC,CAAe,EAAIF,WAAS,CAAC,EAC5C,CAACG,EAAUC,CAAW,EAAIJ,WAAS,EAAK,EAE9CK,EACE,IAAMC,EAAY,MAAM,WAAW,CAAE,MAAAf,EAAO,EAC3CO,GAAWC,EAAUD,CAAM,EAC5B,CAACG,CAAY,CAAA,EAGT,MAAAM,EAAqB,MAAOC,EAAeC,IAAY,CAC3DL,EAAY,EAAI,EAEZ,GAAA,CACI,aAAAE,EAAY,MAAM,cAAc,CACpC,GAAGE,EACH,MAAAjB,CAAA,CACD,EAEDa,EAAY,EAAK,EACjBF,EAAgBD,EAAe,CAAC,EAChCR,EACEG,EAAEa,GAAS,mBAAqB,mCAAmC,EACnEC,EAAa,OAAA,EAGR,SACAC,EAAO,CACd,OAAAP,EAAY,EAAK,EACjBV,EACEe,GAAS,iBAAmB,kCAC5BE,CAAA,EAGK,EACT,CAAA,EAIA,OAAAC,MAACzB,EAAmB,SAAnB,CAA4B,MAAO,CAAE,OAAAW,EAAQ,KAAAS,EAAM,SAAAJ,GACjD,SAAAb,CACH,CAAA,CAEJ,EAEauB,EAAiB,IAAMC,EAAmB3B,CAAkB"}