import * as React from "react"; import { IconButton, IContextualMenuItem, INavLinkGroup, Nav, Pivot, PivotItem, Stack, useTheme } from "@fluentui/react"; import { useConst } from "@fluentui/react-hooks"; import nlsHPCC from "src/nlsHPCC"; import { MainNav, routes } from "../routes"; import { pushUrl } from "../util/history"; import { useFavorite, useFavorites, useHistory } from "../hooks/favorite"; import { useUserTheme } from "../hooks/theme"; import { Breadcrumbs } from "./Breadcrumbs"; // Top Level Nav --- const navLinkGroups: INavLinkGroup[] = [ { links: [ { name: nlsHPCC.Activities, url: "#/activities", icon: "Home", key: "activities" }, { name: nlsHPCC.ECL, url: "#/workunits", icon: "SetAction", key: "workunits" }, { name: nlsHPCC.Files, url: "#/files", icon: "PageData", key: "files" }, { name: nlsHPCC.PublishedQueries, url: "#/queries", icon: "Globe", key: "queries" }, { name: nlsHPCC.Operations, url: "#/topology", icon: "Admin", key: "topology" } ] } ]; const navIdx: { [id: string]: MainNav[] } = {}; function append(route, path) { if (!navIdx[path]) { navIdx[path] = []; } route.mainNav?.forEach(item => { navIdx[path].push(item); }); } routes.forEach((route: any) => { if (Array.isArray(route.path)) { route.path.forEach(path => { append(route, path); }); } else { append(route, route.path); } }); function navSelectedKey(hashPath) { const rootPath = navIdx[`/${hashPath?.split("/")[1]}`]; if (rootPath?.length) { return rootPath[0]; } return null; } const FIXED_WIDTH = 38; interface MainNavigationProps { hashPath: string; } export const MainNavigation: React.FunctionComponent = ({ hashPath }) => { const menu = useConst([...navLinkGroups]); const [theme, setTheme, isDark] = useUserTheme(); const selKey = React.useMemo(() => { return navSelectedKey(hashPath); }, [hashPath]); return