/** * Main Navigation Sidebar * Displays navigation links for the main application (projects, agents, etc.) * Collapsible on mobile with responsive behavior */ 'use client'; import { useState, useCallback, useEffect } from 'react'; import { Link } from '@/lib/i18n/routing'; import { usePathname } from '@/lib/i18n/routing'; import { cn } from '@/lib/utils'; import { Button } from '@/components/ui/button'; import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetTrigger, } from '@/components/ui/sheet'; import { FolderKanban, Bot, LayoutDashboard, ListTodo, IterationCw, Settings, ChevronLeft, ChevronRight, Menu, Shield, } from 'lucide-react'; import { useAuth } from '@/lib/auth/AuthContext'; interface NavItem { name: string; href: string; icon: React.ComponentType<{ className?: string }>; /** If true, only matches exact path */ exact?: boolean; /** If true, only visible to superusers */ adminOnly?: boolean; } const mainNavItems: NavItem[] = [ { name: 'Projects', href: '/projects', icon: FolderKanban, exact: true, }, ]; const projectNavItems: NavItem[] = [ { name: 'Dashboard', href: '/dashboard', icon: LayoutDashboard, exact: true, }, { name: 'Issues', href: '/issues', icon: ListTodo, }, { name: 'Sprints', href: '/sprints', icon: IterationCw, }, { name: 'Agents', href: '/agents', icon: Bot, }, { name: 'Settings', href: '/settings', icon: Settings, }, ]; const adminNavItems: NavItem[] = [ { name: 'Agent Types', href: '/admin/agent-types', icon: Bot, adminOnly: true, }, { name: 'Admin Panel', href: '/admin', icon: Shield, adminOnly: true, exact: true, }, ]; interface SidebarProps { /** Current project slug, if viewing a project */ projectSlug?: string; /** Additional className */ className?: string; } interface NavLinkProps { item: NavItem; collapsed: boolean; basePath?: string; } function NavLink({ item, collapsed, basePath = '' }: NavLinkProps) { const pathname = usePathname(); const href = basePath ? `${basePath}${item.href}` : item.href; const isActive = item.exact ? pathname === href : pathname.startsWith(href); const Icon = item.icon; return (