2022-06-28 07:42:42 +00:00
|
|
|
import clsx from 'clsx';
|
|
|
|
import { Home } from 'react-feather';
|
|
|
|
|
2022-06-23 07:25:56 +00:00
|
|
|
import { useUser } from '@/portainer/hooks/useUser';
|
|
|
|
import { useIsTeamLeader } from '@/portainer/users/queries';
|
2022-09-21 06:14:29 +00:00
|
|
|
import { usePublicSettings } from '@/react/portainer/settings/queries';
|
2022-06-23 07:25:56 +00:00
|
|
|
|
|
|
|
import styles from './Sidebar.module.css';
|
|
|
|
import { EdgeComputeSidebar } from './EdgeComputeSidebar';
|
|
|
|
import { EnvironmentSidebar } from './EnvironmentSidebar';
|
|
|
|
import { SettingsSidebar } from './SettingsSidebar';
|
|
|
|
import { SidebarItem } from './SidebarItem';
|
|
|
|
import { Footer } from './Footer';
|
|
|
|
import { Header } from './Header';
|
|
|
|
import { SidebarProvider } from './useSidebarState';
|
|
|
|
|
|
|
|
export function Sidebar() {
|
|
|
|
const { isAdmin, user } = useUser();
|
2022-08-03 21:23:38 +00:00
|
|
|
const isTeamLeader = useIsTeamLeader(user) as boolean;
|
2022-06-23 07:25:56 +00:00
|
|
|
|
|
|
|
const settingsQuery = usePublicSettings();
|
|
|
|
|
|
|
|
if (!settingsQuery.data) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { EnableEdgeComputeFeatures, LogoURL } = settingsQuery.data;
|
|
|
|
|
|
|
|
return (
|
|
|
|
/* in the future (when we remove r2a) this should wrap the whole app - to change root styles */
|
|
|
|
<SidebarProvider>
|
2022-09-08 01:49:09 +00:00
|
|
|
<nav className={clsx(styles.root, 'p-5 flex flex-col')} aria-label="Main">
|
2022-06-23 07:25:56 +00:00
|
|
|
<Header logo={LogoURL} />
|
2022-06-28 07:42:42 +00:00
|
|
|
|
|
|
|
{/* negative margin + padding -> scrollbar won't hide the content */}
|
|
|
|
<div className="mt-6 overflow-y-auto flex-1 -mr-4 pr-4">
|
|
|
|
<ul className="space-y-9">
|
2022-06-28 16:36:40 +00:00
|
|
|
<SidebarItem
|
|
|
|
to="portainer.home"
|
|
|
|
icon={Home}
|
|
|
|
label="Home"
|
|
|
|
data-cy="portainerSidebar-home"
|
|
|
|
/>
|
2022-06-23 07:25:56 +00:00
|
|
|
|
|
|
|
<EnvironmentSidebar />
|
|
|
|
|
|
|
|
{isAdmin && EnableEdgeComputeFeatures && <EdgeComputeSidebar />}
|
|
|
|
|
2022-09-23 05:17:44 +00:00
|
|
|
<SettingsSidebar isAdmin={isAdmin} isTeamLeader={isTeamLeader} />
|
2022-06-23 07:25:56 +00:00
|
|
|
</ul>
|
|
|
|
</div>
|
|
|
|
|
2022-06-28 07:42:42 +00:00
|
|
|
<div className="mt-auto pt-8">
|
|
|
|
<Footer />
|
|
|
|
</div>
|
2022-06-23 07:25:56 +00:00
|
|
|
</nav>
|
|
|
|
</SidebarProvider>
|
|
|
|
);
|
|
|
|
}
|