Skip to content

Commit

Permalink
Remove the Environment Banner from production environment (#1652)
Browse files Browse the repository at this point in the history
* Environment Banner

* update for includes
  • Loading branch information
djnunez-aot authored Jan 11, 2024
1 parent 6e4874e commit 16ed717
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 8 deletions.
15 changes: 7 additions & 8 deletions epictrack-web/src/components/layout/Header/EnvironmentBanner.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,16 @@ import { useAppDispatch } from "../../../hooks";
import { envBanner } from "../../../styles/uiStateSlice";
import InfoIcon from "../../../assets/images/infoIcon.svg";
import { ETSubhead } from "../../shared";

import { AppConfig } from "../../../config";
const EnvironmentBanner = () => {
const dispatch = useAppDispatch();
const host = window.location.hostname;
const isTestEnvironment =
host.indexOf("dev") !== -1 ||
host.indexOf("test") !== -1 ||
host.indexOf("demo") !== -1 ||
host.indexOf("localhost") !== -1;
const env = AppConfig.environment;
const isTestEnvironment = ["dev", "test", "demo", "localhost"].includes(env);

React.useEffect(() => {
dispatch(envBanner(isTestEnvironment));
}, []);

if (!isTestEnvironment) {
return (
<Box
Expand All @@ -28,6 +26,7 @@ const EnvironmentBanner = () => {
></Box>
);
}

return (
<Box
sx={{
Expand All @@ -44,7 +43,7 @@ const EnvironmentBanner = () => {
textAlign="center"
>
<Box component="img" src={InfoIcon} alt="EPIC.track" />
<ETSubhead>You are using a TEST environment</ETSubhead>
<ETSubhead>You are using a {env.toUpperCase()} environment</ETSubhead>
</Box>
);
};
Expand Down
4 changes: 4 additions & 0 deletions epictrack-web/src/config.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ declare global {
REACT_APP_KEYCLOAK_URL: string;
REACT_APP_KEYCLOAK_CLIENT: string;
REACT_APP_KEYCLOAK_REALM: string;
REACT_APP_ENV: string;
};
}
}
Expand All @@ -22,9 +23,12 @@ const KC_CLIENT =
const KC_REALM =
window._env_?.REACT_APP_KEYCLOAK_REALM ||
process.env.REACT_APP_KEYCLOAK_REALM;
const APP_ENVIRONMENT =
window._env_?.REACT_APP_ENV || process.env.REACT_APP_ENV || "";

export const AppConfig = {
apiUrl: `${API_URL}/api/v1/`,
environment: APP_ENVIRONMENT,
keycloak: {
url: KC_URL || "",
clientId: KC_CLIENT || "",
Expand Down

0 comments on commit 16ed717

Please sign in to comment.