|
| 1 | +"use client" |
| 2 | + |
| 3 | +import Link from 'next/link' |
| 4 | +import type { Route } from 'next' |
| 5 | +import { usePathname } from 'next/navigation' |
| 6 | +import { cn } from '@/lib/utils' |
| 7 | +import { |
| 8 | + LayoutDashboard, |
| 9 | + Bot, |
| 10 | + Workflow, |
| 11 | + Network, |
| 12 | + Wrench, |
| 13 | + Settings, |
| 14 | +} from 'lucide-react' |
| 15 | + |
| 16 | +type NavItem = { |
| 17 | + title: string |
| 18 | + href: Route |
| 19 | + icon: React.ComponentType<{ className?: string }> |
| 20 | + description: string |
| 21 | +} |
| 22 | + |
| 23 | +const navItems: NavItem[] = [ |
| 24 | + { |
| 25 | + title: 'Overview', |
| 26 | + href: '/admin' as Route, |
| 27 | + icon: LayoutDashboard, |
| 28 | + description: 'Quick launch + discovery', |
| 29 | + }, |
| 30 | + { |
| 31 | + title: 'Agents', |
| 32 | + href: '/admin/agents' as Route, |
| 33 | + icon: Bot, |
| 34 | + description: 'All configured agents', |
| 35 | + }, |
| 36 | + { |
| 37 | + title: 'Workflows', |
| 38 | + href: '/admin/workflows' as Route, |
| 39 | + icon: Workflow, |
| 40 | + description: 'All workflows + steps', |
| 41 | + }, |
| 42 | + { |
| 43 | + title: 'Networks', |
| 44 | + href: '/admin/networks' as Route, |
| 45 | + icon: Network, |
| 46 | + description: 'Agent routing networks', |
| 47 | + }, |
| 48 | + { |
| 49 | + title: 'Tools', |
| 50 | + href: '/admin/tools' as Route, |
| 51 | + icon: Wrench, |
| 52 | + description: 'Tooling overview', |
| 53 | + }, |
| 54 | + { |
| 55 | + title: 'Settings', |
| 56 | + href: '/admin/settings' as Route, |
| 57 | + icon: Settings, |
| 58 | + description: 'Local preferences', |
| 59 | + }, |
| 60 | +] |
| 61 | + |
| 62 | +export function AdminSidebar() { |
| 63 | + const pathname = usePathname() |
| 64 | + |
| 65 | + return ( |
| 66 | + <aside className="hidden w-80 shrink-0 border-r bg-card lg:block"> |
| 67 | + <div className="sticky top-0 flex h-screen flex-col"> |
| 68 | + <div className="border-b p-6"> |
| 69 | + <div className="text-sm text-muted-foreground">AgentStack</div> |
| 70 | + <div className="text-lg font-semibold">Admin</div> |
| 71 | + </div> |
| 72 | + |
| 73 | + <nav className="flex-1 space-y-1 p-3"> |
| 74 | + {navItems.map((item) => { |
| 75 | + const active = pathname === item.href || pathname?.startsWith(`${item.href}/`) |
| 76 | + const Icon = item.icon |
| 77 | + |
| 78 | + return ( |
| 79 | + <Link |
| 80 | + key={item.href} |
| 81 | + href={item.href} |
| 82 | + className={cn( |
| 83 | + 'flex items-start gap-3 rounded-lg px-3 py-3 transition-colors', |
| 84 | + active |
| 85 | + ? 'bg-primary/10 text-foreground' |
| 86 | + : 'text-muted-foreground hover:bg-muted/60 hover:text-foreground' |
| 87 | + )} |
| 88 | + > |
| 89 | + <Icon className="mt-0.5 h-5 w-5" /> |
| 90 | + <div className="min-w-0"> |
| 91 | + <div className="font-medium leading-none">{item.title}</div> |
| 92 | + <div className="mt-1 text-xs leading-snug text-muted-foreground"> |
| 93 | + {item.description} |
| 94 | + </div> |
| 95 | + </div> |
| 96 | + </Link> |
| 97 | + ) |
| 98 | + })} |
| 99 | + </nav> |
| 100 | + |
| 101 | + <div className="border-t p-4 text-xs text-muted-foreground"> |
| 102 | + Protected area • Dev session cookie |
| 103 | + </div> |
| 104 | + </div> |
| 105 | + </aside> |
| 106 | + ) |
| 107 | +} |
0 commit comments