import React, { useState, useEffect, useCallback } from 'react'; import { Button } from '@/components/ui/index'; import { RefreshCw } from 'lucide-react'; import { VMList } from '@/components/Proxmox'; import { listProxmoxClusters, listProxmoxVms } from '@/lib/proxmoxClient'; import type { ClusterInfo } from '@/lib/domain'; import { toast } from 'sonner'; export function ProxmoxVMsPage() { const [clusters, setClusters] = useState([]); const [selectedClusterId, setSelectedClusterId] = useState(''); // eslint-disable-next-line @typescript-eslint/no-explicit-any const [vms, setVms] = useState([]); const [isLoading, setIsLoading] = useState(false); const [selectedVMs, setSelectedVMs] = useState>(new Set()); useEffect(() => { listProxmoxClusters() .then((cls) => { setClusters(cls); if (cls.length > 0) setSelectedClusterId(cls[0].id); }) .catch((err) => { console.error('Failed to load clusters:', err); toast.error('Failed to load clusters'); }); }, []); const loadVms = useCallback(async (clusterId: string) => { if (!clusterId) return; setIsLoading(true); try { const data = await listProxmoxVms(clusterId); setVms(data); } catch (err) { console.error('Failed to load VMs:', err); toast.error('Failed to load VMs'); } finally { setIsLoading(false); } }, []); useEffect(() => { if (selectedClusterId) loadVms(selectedClusterId); }, [selectedClusterId, loadVms]); if (clusters.length === 0 && !isLoading) { return (

Virtual Machines

Manage QEMU/KVM virtual machines

No Proxmox clusters configured.

Add a remote connection first.

); } return (

Virtual Machines

Manage QEMU/KVM virtual machines

{clusters.length > 1 && ( )}
loadVms(selectedClusterId)} onVMAction={(_vm, _action) => { toast.info('VM action — not yet implemented'); }} onSnapshotAction={(_vm, _action) => { toast.info('Snapshot action — not yet implemented'); }} onMigrate={(_vm) => { toast.info('Migrate — not yet implemented'); }} onClone={(_vm) => { toast.info('Clone — not yet implemented'); }} onDelete={(_vm) => { toast.info('Delete — not yet implemented'); }} selectedVMs={selectedVMs} onToggleSelect={(vm) => { setSelectedVMs((prev) => { const next = new Set(prev); const id = String(vm.vmid); if (next.has(id)) next.delete(id); else next.add(id); return next; }); }} />
); }