import React from 'react'; import { NavLink, useLocation } from 'react-router-dom'; import { Paper, Tab, Tabs, Theme } from '@mui/material'; import useUiConfig from 'hooks/api/getters/useUiConfig/useUiConfig'; import { useInstanceStatus } from 'hooks/api/getters/useInstanceStatus/useInstanceStatus'; import { useTheme } from '@mui/material/styles'; const createNavLinkStyle = (props: { isActive: boolean; theme: Theme; }): React.CSSProperties => { const navLinkStyle = { display: 'flex', justifyContent: 'center', alignItems: 'center', width: '100%', textDecoration: 'none', color: 'inherit', padding: props.theme.spacing(1.5, 3), }; const activeNavLinkStyle: React.CSSProperties = { fontWeight: 'bold', borderRadius: '3px', padding: props.theme.spacing(1.5, 3), }; return props.isActive ? { ...navLinkStyle, ...activeNavLinkStyle } : navLinkStyle; }; function AdminMenu() { const { uiConfig } = useUiConfig(); const theme = useTheme(); const { pathname } = useLocation(); const { isBilling } = useInstanceStatus(); const { flags } = uiConfig; return ( createNavLinkStyle({ isActive, theme }) } > Users } /> {flags.UG && ( createNavLinkStyle({ isActive, theme }) } > Groups } /> )} {flags.RE && ( createNavLinkStyle({ isActive, theme }) } > Project roles } /> )} createNavLinkStyle({ isActive, theme }) } > API access } /> {uiConfig.flags.embedProxyFrontend && ( createNavLinkStyle({ isActive, theme }) } > CORS origins } /> )} createNavLinkStyle({ isActive, theme }) } > Single sign-on } /> createNavLinkStyle({ isActive, theme }) } > Instance stats } /> {isBilling && ( createNavLinkStyle({ isActive, theme }) } > Billing } /> )} ); } export default AdminMenu;