import { useState } from 'react' import { FileText, FolderOpen, Package, PanelLeftClose, PanelLeftOpen, Server, } from 'lucide-react' import { Button } from '~/components/ui/button' import { ScrollArea } from '~/components/ui/scroll-area' import { cn } from '~/lib/utils' import { useBootstrapConfig } from '~/modules/config/BootstrapConfigContext' interface HierarchyNode { id: string label: string type: 'env' | 'app' | 'group' | 'page' children?: Array } interface LeftPanelProps { className?: string } // Function to build hierarchy data from real context data (most visited) function buildHierarchyFromContext(indexData: any): Array { const hierarchyData: Array = [] // Take a subset of environments representing most visited const envs = Object.values(indexData.envs).slice(0, 3) // Take first 3 environments envs.forEach((env: any) => { const envNode: HierarchyNode = { id: `env-${env.slug}`, label: env.displayName || env.slug, type: 'env', children: [], } // Take a subset of apps for each environment (most visited) const apps = Object.values(indexData.apps).slice(0, 3) // Take first 3 apps per env apps.forEach((app: any) => { const appNode: HierarchyNode = { id: `env-${env.slug}-app-${app.slug}`, label: app.displayName || app.slug, type: 'app', children: [], } // Add a few top pages if the app has UI structure if (app.ui && app.ui.groups && app.ui.groups.length > 0) { // Take the first group and show some pages directly under the app const firstGroup = app.ui.groups[0] if (firstGroup.pages && firstGroup.pages.length > 0) { firstGroup.pages.slice(0, 2).forEach((page: any) => { // Limit to 2 pages per app appNode.children!.push({ id: `env-${env.slug}-app-${app.slug}-page-${page.slug}`, label: page.title || page.slug, type: 'page', }) }) } } else { // If no groups, create a main page appNode.children!.push({ id: `env-${env.slug}-app-${app.slug}-page-main`, label: 'Dashboard', type: 'page', }) } envNode.children!.push(appNode) }) hierarchyData.push(envNode) }) return hierarchyData } function getIconForType(type: HierarchyNode['type']) { switch (type) { case 'env': return case 'app': return case 'group': return case 'page': return default: return null } } interface HierarchyItemProps { node: HierarchyNode level: number } function HierarchyItem({ node, level }: HierarchyItemProps) { const hasChildren = node.children && node.children.length > 0 const indent = level * 20 // 20px per level for better visual hierarchy return (
{getIconForType(node.type)}
{node.label}
{hasChildren && (
{node.children!.map((child) => ( ))}
)}
) } export function LeftPanel({ className }: LeftPanelProps) { const [isCollapsed, setIsCollapsed] = useState(false) const indexData = useBootstrapConfig() // Build hierarchy data from real context data const hierarchyData = buildHierarchyFromContext(indexData) return (
{/* Collapse/Expand Button */} {isCollapsed && (
)} {/* Panel */}
{/* Header */}

Most Visited

{/* Hierarchy Content */}
{hierarchyData.map((node) => ( ))}
) }