import { Box, Layers } from 'lucide-react'; import React, { memo, useState } from 'react'; import { useI18n } from '../../application/i18n/I18nProvider'; import { useContainerRuntimeSelection } from '../../application/state/systemManager/useContainerRuntimeSelection'; import type { useSystemManagerBackend } from '../../application/state/useSystemManagerBackend'; import type { ContainerSourceId } from '../../domain/systemManager/containerRuntime'; import type { SessionCapabilities } from '../../domain/systemManager/types'; import type { TerminalSession } from '../../types'; import { cn } from '../../lib/utils'; import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select'; import { DockerContainersPanel } from './DockerContainersPanel'; import { DockerImagesPanel } from './DockerImagesPanel'; import { KubernetesPodsPanel } from './KubernetesPodsPanel'; import { SystemPanelShell } from './SystemPanelUi'; type Backend = ReturnType; type DockerSubTab = 'containers' | 'images'; const RUNTIME_LABEL: Record = { docker: 'systemManager.runtime.docker', podman: 'systemManager.runtime.podman', nerdctl: 'systemManager.runtime.nerdctl', kubernetes: 'systemManager.runtime.kubernetes', }; interface DockerManagerTabProps { sessionId: string; parentSession: TerminalSession; capabilities?: SessionCapabilities; isVisible: boolean; warmupEnabled?: boolean; backend: Backend; listRefreshIntervalSec: number; statsRefreshIntervalSec: number; } function CompactSelect({ value, options, ariaLabel, section, onChange, className, }: { value: string; options: { id: string; label: string }[]; ariaLabel: string; section: string; onChange: (value: string) => void; className?: string; }) { return ( ); } export const DockerManagerTab = memo(function DockerManagerTab({ sessionId, parentSession, capabilities, isVisible, warmupEnabled = false, backend, listRefreshIntervalSec, statsRefreshIntervalSec, }: DockerManagerTabProps) { const { t } = useI18n(); const [subTab, setSubTab] = useState('containers'); const { source, selectSource, contextName, selectContext, namespaceName, setNamespaceName, contexts, namespaces, scopeError, reloadScopes, runtime, detected, showRuntimeSwitcher, } = useContainerRuntimeSelection({ sessionId, hostKey: parentSession.hostId || sessionId, capabilities, backend, }); const tabs: { id: DockerSubTab; icon: typeof Box; label: string }[] = [ { id: 'containers', icon: Box, label: t('systemManager.docker.subTabs.containers') }, { id: 'images', icon: Layers, label: t('systemManager.docker.subTabs.images') }, ]; return (
{source !== 'kubernetes' && tabs.map(({ id, icon: Icon, label }) => ( ))} {showRuntimeSwitcher && source && detected.includes(source) && ( ({ id, label: t(RUNTIME_LABEL[id]) }))} onChange={selectSource} /> )} {source === 'kubernetes' && contextName && contexts.some((item) => item.name === contextName) && ( ({ id: item.name, label: item.name }))} onChange={selectContext} /> )} {source === 'kubernetes' && namespaceName && namespaces.includes(namespaceName) && ( ({ id: name, label: name }))} onChange={setNamespaceName} /> )}
{source && source !== 'kubernetes' && ( <>
)} {source === 'kubernetes' && ( )}
); });