changed how whoAmI uses the admin client (#216)
this avoids a circle dependency on realm
This commit is contained in:
parent
b06cea6fd9
commit
9eabcdbee4
3 changed files with 20 additions and 20 deletions
17
src/App.tsx
17
src/App.tsx
|
@ -6,7 +6,6 @@ import { Header } from "./PageHeader";
|
||||||
import { PageNav } from "./PageNav";
|
import { PageNav } from "./PageNav";
|
||||||
import { Help } from "./components/help-enabler/HelpHeader";
|
import { Help } from "./components/help-enabler/HelpHeader";
|
||||||
|
|
||||||
import { WhoAmIContextProvider } from "./context/whoami/WhoAmI";
|
|
||||||
import { ServerInfoProvider } from "./context/server-info/ServerInfoProvider";
|
import { ServerInfoProvider } from "./context/server-info/ServerInfoProvider";
|
||||||
import { AlertProvider } from "./components/alert/Alerts";
|
import { AlertProvider } from "./components/alert/Alerts";
|
||||||
|
|
||||||
|
@ -16,15 +15,13 @@ import { PageBreadCrumbs } from "./components/bread-crumb/PageBreadCrumbs";
|
||||||
import { ForbiddenSection } from "./ForbiddenSection";
|
import { ForbiddenSection } from "./ForbiddenSection";
|
||||||
|
|
||||||
const AppContexts = ({ children }: { children: ReactNode }) => (
|
const AppContexts = ({ children }: { children: ReactNode }) => (
|
||||||
<WhoAmIContextProvider>
|
<AccessContextProvider>
|
||||||
<AccessContextProvider>
|
<Help>
|
||||||
<Help>
|
<AlertProvider>
|
||||||
<AlertProvider>
|
<ServerInfoProvider>{children}</ServerInfoProvider>
|
||||||
<ServerInfoProvider>{children}</ServerInfoProvider>
|
</AlertProvider>
|
||||||
</AlertProvider>
|
</Help>
|
||||||
</Help>
|
</AccessContextProvider>
|
||||||
</AccessContextProvider>
|
|
||||||
</WhoAmIContextProvider>
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// If someone tries to go directly to a route they don't
|
// If someone tries to go directly to a route they don't
|
||||||
|
|
|
@ -1,8 +1,8 @@
|
||||||
import React from "react";
|
import React, { useContext } from "react";
|
||||||
import i18n from "../../i18n";
|
import i18n from "../../i18n";
|
||||||
|
|
||||||
import { DataLoader } from "../../components/data-loader/DataLoader";
|
import { DataLoader } from "../../components/data-loader/DataLoader";
|
||||||
import { useAdminClient } from "../auth/AdminClient";
|
import { AdminClient } from "../auth/AdminClient";
|
||||||
import WhoAmIRepresentation, {
|
import WhoAmIRepresentation, {
|
||||||
AccessType,
|
AccessType,
|
||||||
} from "keycloak-admin/lib/defs/whoAmIRepresentation";
|
} from "keycloak-admin/lib/defs/whoAmIRepresentation";
|
||||||
|
@ -53,7 +53,7 @@ export const WhoAmIContext = React.createContext(new WhoAmI());
|
||||||
|
|
||||||
type WhoAmIProviderProps = { children: React.ReactNode };
|
type WhoAmIProviderProps = { children: React.ReactNode };
|
||||||
export const WhoAmIContextProvider = ({ children }: WhoAmIProviderProps) => {
|
export const WhoAmIContextProvider = ({ children }: WhoAmIProviderProps) => {
|
||||||
const adminClient = useAdminClient();
|
const adminClient = useContext(AdminClient)!;
|
||||||
|
|
||||||
const whoAmILoader = async () => {
|
const whoAmILoader = async () => {
|
||||||
if (adminClient.keycloak === undefined) return undefined;
|
if (adminClient.keycloak === undefined) return undefined;
|
||||||
|
|
|
@ -2,20 +2,23 @@ import React from "react";
|
||||||
import ReactDom from "react-dom";
|
import ReactDom from "react-dom";
|
||||||
import i18n from "./i18n";
|
import i18n from "./i18n";
|
||||||
|
|
||||||
import { AdminClient } from "./context/auth/AdminClient";
|
|
||||||
import init from "./context/auth/keycloak";
|
import init from "./context/auth/keycloak";
|
||||||
import { App } from "./App";
|
import { AdminClient } from "./context/auth/AdminClient";
|
||||||
import { RealmContextProvider } from "./context/realm-context/RealmContext";
|
import { RealmContextProvider } from "./context/realm-context/RealmContext";
|
||||||
|
import { WhoAmIContextProvider } from "./context/whoami/WhoAmI";
|
||||||
|
import { App } from "./App";
|
||||||
|
|
||||||
console.info("supported languages", ...i18n.languages);
|
console.info("supported languages", ...i18n.languages);
|
||||||
|
|
||||||
init().then((adminClient) => {
|
init().then((adminClient) => {
|
||||||
ReactDom.render(
|
ReactDom.render(
|
||||||
<RealmContextProvider>
|
<AdminClient.Provider value={adminClient}>
|
||||||
<AdminClient.Provider value={adminClient}>
|
<WhoAmIContextProvider>
|
||||||
<App />
|
<RealmContextProvider>
|
||||||
</AdminClient.Provider>
|
<App />
|
||||||
</RealmContextProvider>,
|
</RealmContextProvider>
|
||||||
|
</WhoAmIContextProvider>
|
||||||
|
</AdminClient.Provider>,
|
||||||
document.getElementById("app")
|
document.getElementById("app")
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue