Files
openshell_controller/app/components/Sidebar.tsx
T

119 lines
4.9 KiB
TypeScript

"use client"
interface SidebarProps {
sandboxesRunning: number
sandboxesTotal: number
activeView: 'settings' | 'sandboxes'
isCreateMode: boolean
isDestroyMode: boolean
onSandboxesClick: () => void
onCreateClick: () => void
onDestroyClick: () => void
onSettingsClick: () => void
onExitMode: () => void
}
export default function Sidebar({
sandboxesRunning,
sandboxesTotal,
activeView,
isCreateMode,
isDestroyMode,
onSandboxesClick,
onCreateClick,
onDestroyClick,
onSettingsClick,
onExitMode,
}: SidebarProps) {
return (
<aside className="fixed left-0 top-0 h-screen w-64 bg-[var(--background-secondary)] border-r border-[var(--border-subtle)] flex flex-col z-20">
<div className="p-4 border-b border-[var(--border-subtle)]">
<div className="flex items-center gap-3">
<div className="w-8 h-8 bg-[var(--nvidia-green)] rounded-sm flex items-center justify-center">
<svg className="w-5 h-5 text-white" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M4 7l8-4 8 4v10l-8 4-8-4V7z" />
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M4 7l8 4 8-4M12 11v10" />
</svg>
</div>
<div>
<p className="text-sm font-semibold text-[var(--foreground)] tracking-tight">OpenShell Control</p>
<p className="text-[10px] text-[var(--foreground-dim)] font-mono mt-1">
{sandboxesRunning} running / {sandboxesTotal} total
</p>
</div>
</div>
</div>
<nav className="flex-1 p-2">
<button
onClick={onSandboxesClick}
className={`w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'sandboxes' && !isCreateMode && !isDestroyMode
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M20 7l-8-4-8 4m16 0l-8 4m8-4v10l-8 4m0-10L4 7m8 4v10M4 7v10l8 4" />
</svg>
<span className="text-sm">Sandboxes</span>
</button>
<button
onClick={onCreateClick}
className={`mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isCreateMode
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 4v16m8-8H4" />
</svg>
<span className="text-sm">Create Sandbox</span>
</button>
<button
onClick={onDestroyClick}
className={`mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
isDestroyMode
? 'bg-[var(--status-stopped)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6M4 7h16" />
</svg>
<span className="text-sm">Destroy Sandbox</span>
</button>
{(isCreateMode || isDestroyMode) && (
<button
onClick={onExitMode}
className="mt-1 w-full flex items-center gap-3 px-3 py-2 rounded-sm bg-[var(--background-tertiary)] text-[var(--foreground-dim)] hover:bg-[var(--background-panel)] transition-colors"
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M6 18L18 6M6 6l12 12" />
</svg>
<span className="text-sm">Cancel</span>
</button>
)}
<button
onClick={onSettingsClick}
className={`mt-4 w-full flex items-center gap-3 px-3 py-2 rounded-sm transition-colors ${
activeView === 'settings'
? 'bg-[var(--nvidia-green)] text-white'
: 'hover:bg-[var(--background-tertiary)] text-[var(--foreground-dim)]'
}`}
>
<svg className="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path strokeLinecap="square" strokeLinejoin="miter" strokeWidth={2} d="M12 6v6l4 2m5-2a9 9 0 11-18 0 9 9 0 0118 0z" />
</svg>
<span className="text-sm">Inference Endpoints</span>
</button>
</nav>
</aside>
)
}