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 @@ - -
+ +
+
@@ -243,7 +257,15 @@ @else
@foreach($drives as $driveKey => $drive) -
+
@@ -253,43 +275,55 @@

{{ $drive['label'] }}

{{ $driveKey }} - @if($drive['ssd']) - SSD - @endif - @if($drive['iothread']) - IO Thread - @endif + +
{{ number_format($drive['size'], 1) }} GB - Cache: {{ ucfirst($drive['cache']) }} - AIO: {{ $drive['aio'] }} - @if($drive['discard']) - Discard enabled - @endif + Cache: {{ ucfirst($drive['cache']) }} + AIO: {{ $drive['aio'] }} +
- -
@endif + + + @if($showDetachModal && $detachingDriveKey && isset($drives[$detachingDriveKey])) + @php $detachDrive = $drives[$detachingDriveKey]; @endphp +
+
+
+
+
+
+
+ +
+

Detach Drive

+
+ +
+ +
+
+

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.

+
+
+ + @if($status && $status->status !== 'stopped') +
+ + VM must be stopped to detach drives. +
+ @endif +
+ +
+ + +
+
+
+
+ @endif + + + @if($showDeleteModal && $deletingDriveKey && isset($drives[$deletingDriveKey])) + @php $deleteDrive = $drives[$deletingDriveKey]; @endphp +
+
+
+
+
+
+
+ +
+

Delete Drive

+
+ +
+ +
+
+

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!

+
+
+ + @if($status && $status->status !== 'stopped') +
+ + VM must be stopped to delete drives. +
+ @endif +
+ +
+ + +
+
+
+
+ @endif