/* eslint-disable */ // @ts-nocheck import { useEnvironment } from "../shared/keycloak-ui-shared"; import { Label, Nav, NavGroup, PageSidebar, PageSidebarBody, } from "../shared/@patternfly/react-core"; import { FormEvent } from "react"; import { useTranslation } from "react-i18next"; import { NavLink, useNavigate } from "react-router-dom"; import { useAccess } from "./context/access/Access"; import { useRealm } from "./context/realm-context/RealmContext"; import { useServerInfo } from "./context/server-info/ServerInfoProvider"; import type { Environment } from "./environment-types"; import { toPage } from "./page/routes"; import { routes } from "./routes"; import { resolveDisplayName } from "./util"; import useIsFeatureEnabled, { Feature } from "./utils/useIsFeatureEnabled"; import "./page-nav.css"; type LeftNavProps = { title: string; path: string; id?: string; }; const LeftNav = ({ title, path, id }: LeftNavProps) => { const { t } = useTranslation(); const { hasAccess } = useAccess(); const { realm } = useRealm(); const encodedRealm = encodeURIComponent(realm); const route = routes.find( (route) => route.path.replace(/\/:.+?(\?|(?:(?!\/).)*|$)/g, "") === (id || path), ); const accessAllowed = route && (route.handle.access instanceof Array ? hasAccess(...route.handle.access) : hasAccess(route.handle.access)); if (!accessAllowed) { return undefined; } const name = "nav-item" + path.replace("/", "-"); return (
  • `pf-v5-c-nav__link${isActive ? " pf-m-current" : ""}` } > {t(title)}
  • ); }; export const PageNav = () => { const { t } = useTranslation(); const { environment } = useEnvironment(); const { hasSomeAccess } = useAccess(); const { componentTypes } = useServerInfo(); const isFeatureEnabled = useIsFeatureEnabled(); const pages = componentTypes?.["org.keycloak.services.ui.extend.UiPageProvider"]; const navigate = useNavigate(); const { realm, realmRepresentation } = useRealm(); type SelectedItem = { groupId: number | string; itemId: number | string; to: string; event: FormEvent; }; const onSelect = (item: SelectedItem) => { navigate(item.to); item.event.preventDefault(); }; const showManage = hasSomeAccess( "view-realm", "query-groups", "query-users", "query-clients", "query-organizations", "view-events", ); const showConfigure = hasSomeAccess( "view-realm", "query-clients", "view-identity-providers", ); const showWorkflows = hasSomeAccess("realm-admin", "admin") && isFeatureEnabled(Feature.Workflows); const showManageRealm = environment.masterRealm === environment.realm; return ( ); };