import { NavUser } from '@/components/nav-user'; import { Sidebar, SidebarContent, SidebarFooter, SidebarGroup, SidebarGroupContent, SidebarHeader, SidebarMenu, SidebarMenuButton, SidebarMenuItem, SidebarMenuSub, SidebarMenuSubItem, } from '@/components/ui/sidebar'; import { type NavItem } from '@/types'; import { Link } from '@inertiajs/react'; import { BookOpen, CogIcon, Folder, ServerIcon } from 'lucide-react'; import AppLogo from './app-logo'; import { Icon } from '@/components/icon'; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from '@/components/ui/collapsible'; import { useState } from 'react'; const mainNavItems: NavItem[] = [ { title: 'Servers', href: route('servers'), icon: ServerIcon, }, { title: 'Settings', href: route('profile'), icon: CogIcon, }, ]; const footerNavItems: NavItem[] = [ { title: 'Repository', href: 'https://github.com/vitodeploy/vito', icon: Folder, }, { title: 'Documentation', href: 'https://vitodeploy.com', icon: BookOpen, }, ]; export function AppSidebar({ secondNavItems, secondNavTitle }: { secondNavItems?: NavItem[]; secondNavTitle?: string }) { const [open, setOpen] = useState(); return ( {/* This is the first sidebar */} {/* We disable collapsible and adjust width to icon. */} {/* This will make the sidebar appear as icons. */} {mainNavItems.map((item) => ( {item.icon && } {item.title} ))} {footerNavItems.map((item) => ( {item.icon && } {item.title} ))} {/* This is the second sidebar */} {/* We enable collapsible and adjust width to icon. */} {/* This will make the sidebar appear as icons. */} {secondNavItems && secondNavItems.length > 0 && (
{secondNavTitle}
{secondNavItems.map((item) => { const isActive = item.onlyActivePath ? window.location.href === item.href : window.location.href.startsWith(item.href); if (item.children && item.children.length > 0) { return ( setOpen(item)} className="group/collapsible" > {item.icon && } {item.title} {item.children.map((childItem) => ( {childItem.title} ))} ); } return ( {item.icon && } {item.title} ); })}
)}
); }