Spaces:
Paused
Paused
Download frontend/src/components/Sidebar.tsx from data-llm-hub/tensorwall: direct link, hf CLI and curl.
- Browser
- Download file 5.29 kB
-
https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/frontend/src/components/Sidebar.tsx
- Command line
-
hf download hf://spaces/data-llm-hub/tensorwall/frontend/src/components/Sidebar.tsx
-
curl -L -o Sidebar.tsx https://huggingface.co/spaces/data-llm-hub/tensorwall/resolve/main/frontend/src/components/Sidebar.tsx
5.29 kB
| 'use client'; | |
| import { useState } from 'react'; | |
| import Link from 'next/link'; | |
| import { usePathname } from 'next/navigation'; | |
| import { | |
| LayoutDashboard, | |
| AppWindow, | |
| Shield, | |
| ShieldCheck, | |
| MessageSquare, | |
| Settings, | |
| Menu, | |
| X, | |
| LogOut, | |
| Cpu, | |
| FileText, | |
| Users, | |
| Wallet, | |
| } from 'lucide-react'; | |
| import clsx from 'clsx'; | |
| import { useAuth } from '@/lib/auth-context'; | |
| const navigation = [ | |
| { name: 'Dashboard', href: '/', icon: LayoutDashboard }, | |
| { name: 'Applications', href: '/applications', icon: AppWindow }, | |
| { name: 'Guardrails', href: '/policies', icon: Shield }, | |
| { name: 'Security Guard', href: '/security', icon: ShieldCheck }, | |
| { name: 'Budgets', href: '/budgets', icon: Wallet }, | |
| { name: 'Requests', href: '/requests', icon: FileText }, | |
| { name: 'Playground', href: '/playground', icon: MessageSquare }, | |
| ]; | |
| // Admin navigation items | |
| const adminNavigation = [ | |
| { name: 'Models', href: '/admin/models', icon: Cpu }, | |
| { name: 'Users', href: '/users', icon: Users }, | |
| { name: 'Settings', href: '/settings', icon: Settings }, | |
| ]; | |
| export default function Sidebar() { | |
| const pathname = usePathname(); | |
| const { user, logout } = useAuth(); | |
| const [mobileOpen, setMobileOpen] = useState(false); | |
| return ( | |
| <> | |
| {/* Mobile menu button */} | |
| <button | |
| className="lg:hidden fixed top-4 left-4 z-50 p-2 bg-gray-800 rounded-md" | |
| onClick={() => setMobileOpen(!mobileOpen)} | |
| > | |
| {mobileOpen ? <X className="w-6 h-6 text-white" /> : <Menu className="w-6 h-6 text-white" />} | |
| </button> | |
| {/* Sidebar */} | |
| <div className={clsx( | |
| 'fixed inset-y-0 left-0 z-40 w-64 bg-gray-900 transform transition-transform lg:translate-x-0', | |
| mobileOpen ? 'translate-x-0' : '-translate-x-full' | |
| )}> | |
| <div className="flex flex-col h-full"> | |
| {/* Logo */} | |
| <div className="flex items-center h-16 px-6 bg-gray-800"> | |
| <h1 className="text-xl font-bold text-white">TensorWall</h1> | |
| </div> | |
| {/* Navigation */} | |
| <nav className="flex-1 px-4 py-6 space-y-2 overflow-y-auto"> | |
| {/* Regular navigation items */} | |
| {navigation.map((item) => { | |
| const isActive = pathname === item.href; | |
| return ( | |
| <Link | |
| key={item.name} | |
| href={item.href} | |
| onClick={() => setMobileOpen(false)} | |
| className={clsx( | |
| 'flex items-center px-4 py-3 text-sm font-medium rounded-lg transition-colors', | |
| isActive | |
| ? 'bg-blue-600 text-white' | |
| : 'text-gray-300 hover:bg-gray-800 hover:text-white' | |
| )} | |
| > | |
| <item.icon className="w-5 h-5 mr-3" /> | |
| {item.name} | |
| </Link> | |
| ); | |
| })} | |
| {/* Admin section divider */} | |
| <div className="pt-4 mt-4 border-t border-gray-700"> | |
| <p className="px-4 text-xs font-semibold text-gray-500 uppercase tracking-wider mb-2"> | |
| Admin | |
| </p> | |
| {adminNavigation.map((item) => { | |
| const isActive = pathname === item.href; | |
| return ( | |
| <Link | |
| key={item.name} | |
| href={item.href} | |
| onClick={() => setMobileOpen(false)} | |
| className={clsx( | |
| 'flex items-center px-4 py-3 text-sm font-medium rounded-lg transition-colors', | |
| isActive | |
| ? 'bg-blue-600 text-white' | |
| : 'text-gray-300 hover:bg-gray-800 hover:text-white' | |
| )} | |
| > | |
| <item.icon className="w-5 h-5 mr-3" /> | |
| {item.name} | |
| </Link> | |
| ); | |
| })} | |
| </div> | |
| </nav> | |
| {/* User Info & Logout */} | |
| {user && ( | |
| <div className="px-4 py-4 border-t border-gray-700/50"> | |
| <div className="flex items-center gap-3"> | |
| <div className="flex-shrink-0 w-9 h-9 bg-gradient-to-br from-blue-500 to-blue-600 rounded-full flex items-center justify-center shadow-lg"> | |
| <span className="text-sm font-semibold text-white"> | |
| {user.name.charAt(0).toUpperCase()} | |
| </span> | |
| </div> | |
| <div className="flex-1 min-w-0"> | |
| <p className="text-sm font-medium text-white truncate">{user.name}</p> | |
| <p className="text-xs text-gray-500 truncate">{user.email}</p> | |
| </div> | |
| <button | |
| onClick={logout} | |
| className="flex-shrink-0 p-2 text-gray-400 hover:text-white hover:bg-gray-800 rounded-lg transition-colors" | |
| title="Sign Out" | |
| > | |
| <LogOut className="w-4 h-4" /> | |
| </button> | |
| </div> | |
| </div> | |
| )} | |
| {/* Footer */} | |
| <div className="px-6 py-4 border-t border-gray-800"> | |
| <p className="text-xs text-gray-500">v0.1.0 (Community)</p> | |
| </div> | |
| </div> | |
| </div> | |
| </> | |
| ); | |
| } | |