import { Divider, Nav, NavGroup, NavItem, NavList, PageSidebar, } from "@patternfly/react-core"; import { FormEvent } from "react"; import { useTranslation } from "react-i18next"; import { NavLink, useMatch, useNavigate } from "react-router-dom"; import { RealmSelector } from "./components/realm-selector/RealmSelector"; import { useAccess } from "./context/access/Access"; import { useRealm } from "./context/realm-context/RealmContext"; import { AddRealmRoute } from "./realm/routes/AddRealm"; import { routes } from "./route-config"; import "./page-nav.css"; type LeftNavProps = { title: string; path: string }; const LeftNav = ({ title, path }: LeftNavProps) => { const { t } = useTranslation("common"); const { hasAccess } = useAccess(); const { realm } = useRealm(); const route = routes.find( (route) => route.path.replace(/\/:.+?(\?|(?:(?!\/).)*|$)/g, "") === path ); const accessAllowed = route && (route.access instanceof Array ? hasAccess(...route.access) : hasAccess(route.access)); if (!accessAllowed) { return null; } return (