"use client" import * as React from "react" import Link from "next/link" import { usePathname } from "next/navigation" import { cn } from "@/lib/utils" import { Button } from "@/components/ui/button" import { Badge } from "@/components/ui/badge" import { ThemeToggle } from "@/components/ui/theme-toggle" import { UserMenu } from "@/components/ui/user-menu" import { useAuth } from "@/contexts/AuthContext" import { useModules } from "@/contexts/ModulesContext" import { usePlugin } from "@/contexts/PluginContext" import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger, } from "@/components/ui/dropdown-menu" import { ChevronDown } from "lucide-react" // Module to navigation mapping const MODULE_NAV_MAP = { chatbot: { href: "/chatbot", label: "Chatbot" }, rag: { href: "/rag", label: "RAG" }, // Add more mappings as needed } const Navigation = () => { const pathname = usePathname() const { user, logout } = useAuth() const { isModuleEnabled } = useModules() const { installedPlugins, getPluginPages } = usePlugin() const [isClient, setIsClient] = React.useState(false) React.useEffect(() => { setIsClient(true) }, []) // Get plugin navigation items const pluginNavItems = installedPlugins .filter(plugin => plugin.status === 'enabled' && plugin.loaded) .map(plugin => { const pages = getPluginPages(plugin.id); if (pages.length === 0) return null; if (pages.length === 1) { // Single page plugin return { href: `/plugins/${plugin.id}${pages[0].path}`, label: plugin.name }; } else { // Multi-page plugin return { href: `/plugins/${plugin.id}`, label: plugin.name, children: pages.map(page => ({ href: `/plugins/${plugin.id}${page.path}`, label: page.title || page.name })) }; } }) .filter(Boolean); // Core navigation items that are always visible const coreNavItems = [ { href: "/dashboard", label: "Dashboard" }, { href: "/llm", label: "LLM", children: [ { href: "/llm", label: "Models & Config" }, { href: "/playground", label: "Playground" }, ] }, { href: "/settings", label: "Settings", children: [ { href: "/settings", label: "System Settings" }, { href: "/plugins", label: "Plugins" }, { href: "/prompt-templates", label: "Prompt Templates" }, ] }, ] // Dynamic navigation items based on enabled modules const moduleNavItems = Object.entries(MODULE_NAV_MAP) .filter(([moduleName]) => isModuleEnabled(moduleName)) .map(([, navItem]) => navItem) // Combine core, module-based, and plugin navigation items const navItems = [...coreNavItems, ...moduleNavItems, ...pluginNavItems] return (
Enclava {isClient && user && ( )}
) } export { Navigation }