diff --git a/extensions/Servers/Proxmox/Livewire/Storage.php b/extensions/Servers/Proxmox/Livewire/Storage.php index dda7f6c5a..154981183 100644 --- a/extensions/Servers/Proxmox/Livewire/Storage.php +++ b/extensions/Servers/Proxmox/Livewire/Storage.php @@ -109,6 +109,18 @@ class Storage extends Component public ?string $movingDriveKey = null; public string $moveDriveTargetBus = 'scsi'; + /** + * Form state for detach confirmation modal. + */ + public bool $showDetachModal = false; + public ?string $detachingDriveKey = null; + + /** + * Form state for delete confirmation modal. + */ + public bool $showDeleteModal = false; + public ?string $deletingDriveKey = null; + /** * Storage name for cephpool. */ @@ -619,15 +631,40 @@ class Storage extends Component } /** - * Detach a drive (move to unused). + * Open the detach confirmation modal. */ - public function detachDrive(string $driveKey): void + public function openDetachModal(string $driveKey): void { if (!isset($this->drives[$driveKey])) { $this->notify('Drive not found.', 'error'); return; } + $this->detachingDriveKey = $driveKey; + $this->showDetachModal = true; + } + + /** + * Close the detach confirmation modal. + */ + public function closeDetachModal(): void + { + $this->showDetachModal = false; + $this->detachingDriveKey = null; + } + + /** + * Detach a drive (move to unused). + */ + public function detachDrive(): void + { + if (!$this->detachingDriveKey || !isset($this->drives[$this->detachingDriveKey])) { + $this->notify('Drive not found.', 'error'); + return; + } + + $driveKey = $this->detachingDriveKey; + // Check VM status - must be stopped to detach if ($this->status && $this->status->status !== 'stopped') { $this->notify('VM must be stopped to detach drives.', 'error'); @@ -647,6 +684,7 @@ class Storage extends Component ); $this->notify("Drive {$driveKey} detached successfully.", 'success'); + $this->closeDetachModal(); $this->loadStorageConfiguration(false); } catch (\Exception $e) { $this->notify('Failed to detach drive: ' . $e->getMessage(), 'error'); @@ -704,15 +742,40 @@ class Storage extends Component } /** - * Delete a drive permanently. + * Open the delete confirmation modal. */ - public function deleteDrive(string $driveKey): void + public function openDeleteModal(string $driveKey): void { if (!isset($this->drives[$driveKey])) { $this->notify('Drive not found.', 'error'); return; } + $this->deletingDriveKey = $driveKey; + $this->showDeleteModal = true; + } + + /** + * Close the delete confirmation modal. + */ + public function closeDeleteModal(): void + { + $this->showDeleteModal = false; + $this->deletingDriveKey = null; + } + + /** + * Delete a drive permanently. + */ + public function deleteDrive(): void + { + if (!$this->deletingDriveKey || !isset($this->drives[$this->deletingDriveKey])) { + $this->notify('Drive not found.', 'error'); + return; + } + + $driveKey = $this->deletingDriveKey; + // Check VM status if ($this->status && $this->status->status !== 'stopped') { $this->notify('VM must be stopped to delete drives.', 'error'); @@ -752,6 +815,7 @@ class Storage extends Component } $this->notify("Drive {$driveKey} deleted successfully.", 'success'); + $this->closeDeleteModal(); $this->loadStorageConfiguration(false); } catch (\Exception $e) { $this->notify('Failed to delete drive: ' . $e->getMessage(), 'error'); diff --git a/extensions/Servers/Proxmox/views/storage.blade.php b/extensions/Servers/Proxmox/views/storage.blade.php index 07ea63416..860349296 100644 --- a/extensions/Servers/Proxmox/views/storage.blade.php +++ b/extensions/Servers/Proxmox/views/storage.blade.php @@ -135,8 +135,22 @@ - -
Drive: {{ $detachDrive['label'] }} ({{ $detachingDriveKey }})
+Size: {{ number_format($detachDrive['size'], 1) }} GB
+Are you sure you want to detach this drive?
+The data will be preserved but the drive will no longer be accessible to the VM until reattached.
+Drive: {{ $deleteDrive['label'] }} ({{ $deletingDriveKey }})
+Size: {{ number_format($deleteDrive['size'], 1) }} GB
+Are you sure you want to DELETE this drive?
+This action cannot be undone. All data on this drive will be permanently lost!
+