diff --git a/ui/package.json b/ui/package.json index b25e7119b0..37e0949a6e 100644 --- a/ui/package.json +++ b/ui/package.json @@ -108,6 +108,9 @@ "transformIgnorePatterns": [ "/node_modules/(?!d3|d3-array|internmap|delaunator|robust-predicates|reactflow|react-toastify|moment)" ], + "moduleNameMapper": { + "^monaco-editor$": "/node_modules/@monaco-editor/react" + }, "resetMocks": false } } diff --git a/ui/src/App.tsx b/ui/src/App.tsx index 208da3d90e..ec46d56577 100644 --- a/ui/src/App.tsx +++ b/ui/src/App.tsx @@ -11,7 +11,7 @@ import Drawer from "@mui/material/Drawer"; import AppBar from "@mui/material/AppBar"; import Toolbar from "@mui/material/Toolbar"; import CircularProgress from "@mui/material/CircularProgress"; -import { Switch, Route, useLocation } from "react-router-dom"; +import { Switch, Route, useLocation, useHistory } from "react-router-dom"; import { Breadcrumbs } from "./components/common/Breadcrumbs"; import { Routes } from "./components/common/Routes"; import { Login } from "./components/pages/Login"; @@ -64,14 +64,6 @@ const EXCLUDE_APP_BARS: { [key: string]: boolean } = { }; function App(props: AppProps) { - // TODO remove, used for testing ns only installation - // const { systemInfo, error: systemInfoError } = { - // systemInfo: { - // namespaced: true, - // managedNamespace: "test", - // }, - // error: undefined, - // }; const { hostUrl = "", namespace = "" } = props; const pageRef = useRef(); const [pageWidth, setPageWidth] = useState(0); @@ -90,6 +82,18 @@ function App(props: AppProps) { } = useSystemInfoFetch({ host: hostUrl }); const location = useLocation(); + const history = useHistory(); + + useEffect(() => { + if (systemInfo?.namespaced && systemInfo?.managedNamespace) { + const query = new URLSearchParams(location.search); + const ns = query.get("namespace") || ""; + + if (location.pathname === "/" && ns !== systemInfo.managedNamespace) { + history.push(`?namespace=${systemInfo.managedNamespace}`); + } + } + }, [location, history, systemInfo]); useEffect(() => { // Attempt to load user info on app load diff --git a/ui/src/components/common/Breadcrumbs/index.tsx b/ui/src/components/common/Breadcrumbs/index.tsx index dd3a2b9e5a..d8454c422c 100644 --- a/ui/src/components/common/Breadcrumbs/index.tsx +++ b/ui/src/components/common/Breadcrumbs/index.tsx @@ -50,16 +50,20 @@ export function Breadcrumbs() { } else if (pl !== "") { // Pipeline summary view return [ - - Namespace - , - {systemInfo.managedNamespace} + Namespace , + + {systemInfo.managedNamespace} + , ); - }, [location, systemInfo]); + }, [location, systemInfo, ns, pl]); return ( (AppContext); const [viewOption] = useState("view"); const [editOption] = useState("edit"); @@ -334,11 +334,7 @@ export function PipelineCard({ }} > )} - Namespace - , - {namespace} + Namespace , + + {namespace} + , ); - }, [location, systemInfo]); + }, [location, systemInfo, namespace, pl]); return ( { + const query = new URLSearchParams(location.search); + const ns = query.get("namespace") || ""; + + if (location.pathname === "/" && ns !== namespace) { + history.push(`?namespace=${namespace}`); + } + }, [location, history, namespace]); useEffect(() => { // Route changed