diff --git a/src/App.tsx b/src/App.tsx index 4b9fc710ce..179b5a36fe 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -6,7 +6,6 @@ import { Header } from "./PageHeader"; import { PageNav } from "./PageNav"; import { Help } from "./components/help-enabler/HelpHeader"; -import { WhoAmIContextProvider } from "./context/whoami/WhoAmI"; import { ServerInfoProvider } from "./context/server-info/ServerInfoProvider"; import { AlertProvider } from "./components/alert/Alerts"; @@ -16,15 +15,13 @@ import { PageBreadCrumbs } from "./components/bread-crumb/PageBreadCrumbs"; import { ForbiddenSection } from "./ForbiddenSection"; const AppContexts = ({ children }: { children: ReactNode }) => ( - - - - - {children} - - - - + + + + {children} + + + ); // If someone tries to go directly to a route they don't diff --git a/src/context/whoami/WhoAmI.tsx b/src/context/whoami/WhoAmI.tsx index 74b4ae6245..c779bbcb05 100644 --- a/src/context/whoami/WhoAmI.tsx +++ b/src/context/whoami/WhoAmI.tsx @@ -1,8 +1,8 @@ -import React from "react"; +import React, { useContext } from "react"; import i18n from "../../i18n"; import { DataLoader } from "../../components/data-loader/DataLoader"; -import { useAdminClient } from "../auth/AdminClient"; +import { AdminClient } from "../auth/AdminClient"; import WhoAmIRepresentation, { AccessType, } from "keycloak-admin/lib/defs/whoAmIRepresentation"; @@ -53,7 +53,7 @@ export const WhoAmIContext = React.createContext(new WhoAmI()); type WhoAmIProviderProps = { children: React.ReactNode }; export const WhoAmIContextProvider = ({ children }: WhoAmIProviderProps) => { - const adminClient = useAdminClient(); + const adminClient = useContext(AdminClient)!; const whoAmILoader = async () => { if (adminClient.keycloak === undefined) return undefined; diff --git a/src/index.tsx b/src/index.tsx index 3db73c3f4f..241fcb36d6 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -2,20 +2,23 @@ import React from "react"; import ReactDom from "react-dom"; import i18n from "./i18n"; -import { AdminClient } from "./context/auth/AdminClient"; import init from "./context/auth/keycloak"; -import { App } from "./App"; +import { AdminClient } from "./context/auth/AdminClient"; import { RealmContextProvider } from "./context/realm-context/RealmContext"; +import { WhoAmIContextProvider } from "./context/whoami/WhoAmI"; +import { App } from "./App"; console.info("supported languages", ...i18n.languages); init().then((adminClient) => { ReactDom.render( - - - - - , + + + + + + + , document.getElementById("app") ); });