import { useState } from 'react' import { Button } from '@/components/ui/button' import { Input } from '@/components/ui/input' import { Label } from '@/components/ui/label' import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, } from '@/components/ui/dialog' import { useCreateSnapshot } from '@/hooks/useProxmox' import type { ProxmoxVM } from '@/types/proxmox' interface CreateSnapshotDialogProps { open: boolean onOpenChange: (open: boolean) => void vm: ProxmoxVM } export function CreateSnapshotDialog({ open, onOpenChange, vm }: CreateSnapshotDialogProps) { const [name, setName] = useState('') const [description, setDescription] = useState('') const [vmstate, setVmstate] = useState(false) const createSnapshot = useCreateSnapshot() const handleSubmit = (e: React.FormEvent) => { e.preventDefault() createSnapshot.mutate( { node: vm.node, vmid: vm.vmid, vmType: vm.type, config: { name, description: description || undefined, vmstate, }, }, { onSuccess: () => { onOpenChange(false) setName('') setDescription('') setVmstate(false) }, }, ) } return ( Create Snapshot Create a new snapshot for {vm.name} (VMID {vm.vmid})
setName(e.target.value)} placeholder="before-update" required />
setDescription(e.target.value)} placeholder="Before applying system updates" />
setVmstate(e.target.checked)} className="h-4 w-4 rounded border-input accent-primary" />

Including VM state captures the running memory, allowing rollback to the exact running state. This requires more disk space.

{createSnapshot.isError && (

Failed to create snapshot. Please try again.

)}
) }