diff --git a/frontend/src/modules/Nav/SideNav.tsx b/frontend/src/modules/Nav/SideNav.tsx index ff5c97338b..483d5c32ea 100644 --- a/frontend/src/modules/Nav/SideNav.tsx +++ b/frontend/src/modules/Nav/SideNav.tsx @@ -1,8 +1,8 @@ -import React, { useState } from "react"; +import React, { useState, useEffect } from "react"; import { Layout, Menu, Switch as ToggleButton } from "antd"; import { NavLink } from "react-router-dom"; import { useThemeSwitcher } from "react-css-theme-switcher"; -import { useHistory } from "react-router-dom"; +import { useLocation } from "react-router-dom"; import ROUTES from "Src/constants/routes"; import { @@ -19,11 +19,20 @@ const { Sider } = Layout; const SideNav = () => { const { switcher, currentTheme, status, themes } = useThemeSwitcher(); const [collapsed, setCollapsed] = useState(false); - const history = useHistory(); + const [selectedKeys, setSelectedKeys] = useState([ + ROUTES.APPLICATION, + ]); + const location = useLocation(); - if (status === "loading" || history.location.pathname === ROUTES.SIGN_UP) { + useEffect(() => { + const newRoute = location.pathname.split("/")[1]; + setSelectedKeys([`/${newRoute}`]); + }, [location.pathname]); + + if (status === "loading" || location.pathname === ROUTES.SIGN_UP) { return null; } + const toggleTheme = (isChecked: boolean) => { switcher({ theme: isChecked ? themes.dark : themes.light }); }; @@ -53,8 +62,13 @@ const SideNav = () => { - - }> + + }> { Metrics - }> + }> { Traces - }> + }> { Service Map - }> + }> { Usage Explorer - }> + }> { Settings - }> - + }> + Add instrumentation