From 8236528a078c5d80854043607d28e3fa0f58d323 Mon Sep 17 00:00:00 2001 From: Jon Koops Date: Thu, 15 Jul 2021 11:50:01 +0200 Subject: [PATCH] Parse environment information as JSON (#851) * Parse environment information as JSON * Pass 'isRunningAsTheme' from injected environment * Update comment to use index.ftl instead of html Co-authored-by: Stan Silvert * Update realm param comment * Update version param * add more sensible defaults Co-authored-by: Stan Silvert --- build/pom.xml | 29 +++++---- src/PageHeader.tsx | 9 ++- src/context/auth/keycloak.ts | 16 ++--- src/context/realm-context/RealmContext.tsx | 5 +- src/context/whoami/WhoAmI.tsx | 8 --- src/context/whoami/__tests__/WhoAmI.test.tsx | 5 -- src/dashboard/Dashboard.tsx | 5 +- src/environment.ts | 64 ++++++++++++++++++++ src/util.ts | 21 ------- 9 files changed, 100 insertions(+), 62 deletions(-) create mode 100644 src/environment.ts diff --git a/build/pom.xml b/build/pom.xml index e57efb428e..4708bbcf87 100644 --- a/build/pom.xml +++ b/build/pom.xml @@ -68,18 +68,23 @@ href="${resourceUrl}/ - <head> - -<head> - <script type="text/javascript"> - var loginRealm = "${loginRealm}"; - var authServerUrl = "${authServerUrl}"; - var authUrl = "${authUrl}"; - var consoleBaseUrl = "${consoleBaseUrl}"; - var resourceUrl = "${resourceUrl}"; - var masterRealm = "${masterRealm}"; - var resourceVersion = "${resourceVersion}"; - </script> + ]]> + + + { + "loginRealm": "${loginRealm}", + "authServerUrl": "${authServerUrl}", + "authUrl": "${authUrl}", + "consoleBaseUrl": "${consoleBaseUrl}", + "resourceUrl": "${resourceUrl}", + "masterRealm": "${masterRealm}", + "resourceVersion": "${resourceVersion}", + "isRunningAsTheme": true + } + + +]]> diff --git a/src/PageHeader.tsx b/src/PageHeader.tsx index cb7a21d153..955550b6e6 100644 --- a/src/PageHeader.tsx +++ b/src/PageHeader.tsx @@ -18,7 +18,7 @@ import { WhoAmIContext } from "./context/whoami/WhoAmI"; import { HelpContext, HelpHeader } from "./components/help-enabler/HelpHeader"; import { Link, useHistory } from "react-router-dom"; import { useAdminClient } from "./context/auth/AdminClient"; -import { resourceUri } from "./util"; +import environment from "./environment"; export const Header = () => { const adminClient = useAdminClient(); @@ -127,7 +127,10 @@ export const Header = () => { - + ); }; @@ -181,7 +184,7 @@ export const Header = () => { logo={