diff --git a/src/KeycloakAdminConsole.tsx b/src/KeycloakAdminConsole.tsx
new file mode 100644
index 0000000000..1d84127fc9
--- /dev/null
+++ b/src/KeycloakAdminConsole.tsx
@@ -0,0 +1,25 @@
+import React from "react";
+import KeycloakAdminClient from "keycloak-admin";
+
+import { AdminClient } from "./context/auth/AdminClient";
+import { WhoAmIContextProvider } from "./context/whoami/WhoAmI";
+import { RealmContextProvider } from "./context/realm-context/RealmContext";
+import { App } from "./App";
+
+export type KeycloakAdminConsoleProps = {
+ adminClient: KeycloakAdminClient;
+};
+
+export const KeycloakAdminConsole = ({
+ adminClient,
+}: KeycloakAdminConsoleProps) => {
+ return (
+
+
+
+
+
+
+
+ );
+};
diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx
index 86bd789a1d..f6317809e9 100644
--- a/src/PageHeader.tsx
+++ b/src/PageHeader.tsx
@@ -25,23 +25,31 @@ export const Header = () => {
const ManageAccountDropdownItem = () => {
return (
- adminClient.keycloak.accountManagement()}
- >
- {t("manageAccount")}
-
+ <>
+ {adminClient.keycloak && (
+ adminClient.keycloak.accountManagement()}
+ >
+ {t("manageAccount")}
+
+ )}
+ >
);
};
const SignOutDropdownItem = () => {
return (
- adminClient.keycloak.logout({ redirectUri: "" })}
- >
- {t("signOut")}
-
+ <>
+ {adminClient.keycloak && (
+ adminClient.keycloak.logout({ redirectUri: "" })}
+ >
+ {t("signOut")}
+
+ )}
+ >
);
};
diff --git a/src/clients/ClientsSection.tsx b/src/clients/ClientsSection.tsx
index babd090cdf..5033d6237a 100644
--- a/src/clients/ClientsSection.tsx
+++ b/src/clients/ClientsSection.tsx
@@ -77,7 +77,11 @@ export const ClientsSection = () => {
)}
diff --git a/src/context/whoami/WhoAmI.tsx b/src/context/whoami/WhoAmI.tsx
index c779bbcb05..9772aa4e2a 100644
--- a/src/context/whoami/WhoAmI.tsx
+++ b/src/context/whoami/WhoAmI.tsx
@@ -56,8 +56,6 @@ export const WhoAmIContextProvider = ({ children }: WhoAmIProviderProps) => {
const adminClient = useContext(AdminClient)!;
const whoAmILoader = async () => {
- if (adminClient.keycloak === undefined) return undefined;
-
return await adminClient.whoAmI.find();
};
diff --git a/src/index.tsx b/src/index.tsx
index 241fcb36d6..9afcbc3aef 100644
--- a/src/index.tsx
+++ b/src/index.tsx
@@ -3,22 +3,13 @@ import ReactDom from "react-dom";
import i18n from "./i18n";
import init from "./context/auth/keycloak";
-import { AdminClient } from "./context/auth/AdminClient";
-import { RealmContextProvider } from "./context/realm-context/RealmContext";
-import { WhoAmIContextProvider } from "./context/whoami/WhoAmI";
-import { App } from "./App";
+import { KeycloakAdminConsole } from "./KeycloakAdminConsole";
console.info("supported languages", ...i18n.languages);
init().then((adminClient) => {
ReactDom.render(
-
-
-
-
-
-
- ,
+ ,
document.getElementById("app")
);
});