"use client" import { cn } from "@/lib/utils" interface GpuSwitchModeIndicatorProps { mode: "lxc" | "vm" | "unknown" isEditing?: boolean pendingMode?: "lxc" | "vm" | null onToggle?: (e: React.MouseEvent) => void className?: string } export function GpuSwitchModeIndicator({ mode, isEditing = false, pendingMode = null, onToggle, className, }: GpuSwitchModeIndicatorProps) { const displayMode = pendingMode ?? mode const isLxcActive = displayMode === "lxc" const isVmActive = displayMode === "vm" const hasChanged = pendingMode !== null && pendingMode !== mode // Colors const activeColor = isLxcActive ? "#3b82f6" : isVmActive ? "#a855f7" : "#6b7280" const inactiveColor = "#374151" // gray-700 for dark theme const lxcColor = isLxcActive ? "#3b82f6" : inactiveColor const vmColor = isVmActive ? "#a855f7" : inactiveColor const handleClick = (e: React.MouseEvent) => { // Only stop propagation and handle toggle when in editing mode if (isEditing) { e.stopPropagation() if (onToggle) { onToggle(e) } } // When not editing, let the click propagate to the card to open the modal } return (
{/* Large SVG Diagram */} {/* GPU Chip - Large with "GPU" text */} {/* Main chip body */} {/* Chip pins - top */} {/* Chip pins - bottom */} {/* GPU text */} GPU {/* Connection line from GPU to switch */} {/* Central Switch Node - Large circle with inner dot */} {/* LXC Branch Line - going up-right */} {/* VM Branch Line - going down-right */} {/* LXC Container Icon - Server/Stack icon */} {/* Container box */} {/* Container layers/lines */} {/* Status dots */} {/* LXC Label */} LXC {/* VM Monitor Icon */} {/* Monitor screen */} {/* Screen inner/shine */} {/* Monitor stand */} {/* Monitor base */} {/* VM Label */} VM {/* Status Text - Large like GPU name */}
{isLxcActive ? "Ready for LXC containers" : isVmActive ? "Ready for VM passthrough" : "Mode unknown"} {isLxcActive ? "Native driver active" : isVmActive ? "VFIO-PCI driver active" : "No driver detected"} {hasChanged && ( Change pending... )}
) }