import { Box, Clock, Layers, List, Lock, Shuffle, Trello, Clipboard, Edit, Network, } from 'lucide-react'; import { type Environment, type EnvironmentId, } from '@/react/portainer/environments/types'; import { Authorized, useIsEnvironmentAdmin } from '@/react/hooks/useUser'; import { useInfo } from '@/react/docker/proxy/queries/useInfo'; import { useApiVersion } from '@/react/docker/proxy/queries/useVersion'; import { SidebarItem } from './SidebarItem'; import { DashboardLink } from './items/DashboardLink'; import { VolumesLink } from './items/VolumesLink'; import { SidebarParent } from './SidebarItem/SidebarParent'; interface Props { environmentId: EnvironmentId; environment: Environment; } export function DockerSidebar({ environmentId, environment }: Props) { const { authorized: isEnvironmentAdmin } = useIsEnvironmentAdmin({ adminOnlyCE: true, }); const areStacksVisible = isEnvironmentAdmin || environment.SecuritySettings.allowStackManagementForRegularUsers; const envInfoQuery = useInfo(environmentId, { select: (info) => !!info.Swarm?.NodeID && !!info.Swarm?.ControlAvailable, }); const apiVersion = useApiVersion(environmentId); const isSwarmManager = envInfoQuery.data; const setupSubMenuProps = isSwarmManager ? { label: 'Swarm', icon: Trello, to: 'docker.swarm', dataCy: 'portainerSidebar-swarm', } : { label: 'Host', icon: Trello, to: 'docker.host', dataCy: 'portainerSidebar-host', }; const featSubMenuTo = isSwarmManager ? 'docker.swarm.featuresConfiguration' : 'docker.host.featuresConfiguration'; const registrySubMenuTo = isSwarmManager ? 'docker.swarm.registries' : 'docker.host.registries'; return ( <> {areStacksVisible && ( )} {isSwarmManager && ( )} {apiVersion >= 1.3 && isSwarmManager && ( )} {apiVersion >= 1.25 && isSwarmManager && ( )} {!isSwarmManager && isEnvironmentAdmin && ( )} ); }