From c34b1bbd9b791e6679681c7d2c53ed534bb6c6e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dafydd=20Ll=C5=B7r=20Pearson?= Date: Fri, 3 May 2024 14:59:06 +0100 Subject: [PATCH] fix: Conditionally set test env header --- .../src/components/TestEnvironmentBanner.tsx | 15 ++++++++++----- .../src/pages/FlowEditor/lib/store/editor.ts | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/editor.planx.uk/src/components/TestEnvironmentBanner.tsx b/editor.planx.uk/src/components/TestEnvironmentBanner.tsx index ef2de024ab..6f04950c78 100644 --- a/editor.planx.uk/src/components/TestEnvironmentBanner.tsx +++ b/editor.planx.uk/src/components/TestEnvironmentBanner.tsx @@ -6,7 +6,7 @@ import { styled } from "@mui/material/styles"; import Typography from "@mui/material/Typography"; import { visuallyHidden } from "@mui/utils"; import { useStore } from "pages/FlowEditor/lib/store"; -import React, { useState } from "react"; +import React from "react"; const TestEnvironmentWarning = styled(Box)(({ theme }) => ({ backgroundColor: theme.palette.background.paper, @@ -17,7 +17,10 @@ const TestEnvironmentWarning = styled(Box)(({ theme }) => ({ })); const TestEnvironmentBanner: React.FC = () => { - const [isTestEnvBannerVisible, hideTestEnvBanner] = useStore(state => [state.isTestEnvBannerVisible, state.hideTestEnvBanner]); + const [isTestEnvBannerVisible, hideTestEnvBanner] = useStore((state) => [ + state.isTestEnvBannerVisible, + state.hideTestEnvBanner, + ]); if (!isTestEnvBannerVisible) return null; @@ -34,13 +37,15 @@ const TestEnvironmentBanner: React.FC = () => { - This is a testing environment for new features. - Do not use it to make permanent content changes. + This is a testing environment for new features. Do + not use it to make permanent content changes. diff --git a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts index 98bdb902b9..de8a111aad 100644 --- a/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts +++ b/editor.planx.uk/src/pages/FlowEditor/lib/store/editor.ts @@ -55,7 +55,7 @@ export const editorUIStore: StateCreator< set({ showPreview: !get().showPreview }); }, - isTestEnvBannerVisible: true, + isTestEnvBannerVisible: !window.location.href.includes(".uk"), hideTestEnvBanner: () => set({ isTestEnvBannerVisible: false }), });