import { useState } from 'react'; import { Info, FileCode, FolderOpen, BarChart3, Star, X } from 'lucide-react'; import { useTopologyStore } from '../store/topologyStore'; import { getNodeColor, getStatusColor, getImportanceLabel, getImportanceColor } from '../utils/colors'; type TabId = 'details' | 'config' | 'files' | 'usage' | 'importance'; const tabs: { id: TabId; label: string; icon: React.ReactNode }[] = [ { id: 'details', label: 'Details', icon: }, { id: 'config', label: 'Config', icon: }, { id: 'files', label: 'Files', icon: }, { id: 'usage', label: 'Usage', icon: }, { id: 'importance', label: 'Importance', icon: }, ]; export default function RightPanel() { const { nodes, selectedNodeId, setSelectedNode } = useTopologyStore(); const [activeTab, setActiveTab] = useState('details'); const selectedNode = nodes.find(n => n.id === selectedNodeId); if (!selectedNode) { return (
Select a node to view its details
); } const nodeColor = getNodeColor(selectedNode.type, selectedNode.data.category); const statusColor = getStatusColor(selectedNode.data.status); return (

{selectedNode.name}

{tabs.map(tab => ( ))}
{activeTab === 'details' && } {activeTab === 'config' && } {activeTab === 'files' && } {activeTab === 'usage' && } {activeTab === 'importance' && }
); } function DetailsTab({ node, nodeColor, statusColor }: { node: any; nodeColor: string; statusColor: string }) { return (
{node.name.charAt(0).toUpperCase()}
{node.type.replace(/_/g, ' ')}
{node.data.status}
IP Address
{node.data.ip || 'N/A'}
{node.data.description && (
Description
{node.data.description}
)}
Metadata
{JSON.stringify(node.data.metadata, null, 2)}
); } function ConfigTab({ node }: { node: any }) { const hasConfig = node.data.config; if (!hasConfig) { return (
No configuration available
); } return (
        {node.data.config}
      
); } function FilesTab({ node }: { node: any }) { const files = node.data.files || [ '/etc/docker-compose.yml', '/etc/traefik/dynamic.yml', '/var/log/container.log' ]; return (
{files.map((file: string, idx: number) => ( ))}
); } function UsageTab({ node }: { node: any }) { const isService = node.type === 'service'; if (!isService) { return (
Usage data available for services only
); } return (
CPU 12.4%
Memory 256 MB / 1 GB
Network I/O 1.2 MB/s ↓ 0.8 MB/s ↑
); } function ImportanceTab({ node }: { node: any }) { const importance = node.data.importance || 3; const importanceLabel = getImportanceLabel(importance); const importanceColor = getImportanceColor(importance); const reasons = { 5: ['Critical infrastructure', 'Single point of failure', 'Required for other services'], 4: ['Important service', 'Used frequently', 'Difficult to replace'], 3: ['Standard service', 'Can be rebuilt', 'Not critical'], 2: ['Optional service', 'Rarely used', 'Easy to recreate'], 1: ['Development only', 'Non-critical', 'Can be disabled'], }; return (
{[1, 2, 3, 4, 5].map(star => ( ))}
{importanceLabel}
Importance Level {importance}/5
Why this level?
    {reasons[importance as keyof typeof reasons]?.map((reason, idx) => (
  • {reason}
  • ))}
); }