diff --git a/extensions/Servers/Proxmox/Livewire/Storage.php b/extensions/Servers/Proxmox/Livewire/Storage.php index f0c029c6e..d0112753c 100644 --- a/extensions/Servers/Proxmox/Livewire/Storage.php +++ b/extensions/Servers/Proxmox/Livewire/Storage.php @@ -759,6 +759,12 @@ class Storage extends Component return; } + // Check if already at maximum detached drives (2) + if (count($this->unusedDrives) >= 2) { + $this->notify('Maximum of 2 detached drives allowed. Please reattach or delete existing detached drives first.', 'error'); + return; + } + $driveKey = $this->detachingDriveKey; $drive = $this->drives[$driveKey]; @@ -1070,6 +1076,20 @@ class Storage extends Component $unusedDrive = $this->unusedDrives[$this->reattachingDriveKey]; $targetBus = $this->reattachTargetBus; + // Check if reattaching this drive would exceed the storage quota + // Calculate attached drives total (excluding the detached drive being reattached) + $attachedDrivesTotal = 0; + foreach ($this->drives as $drive) { + $attachedDrivesTotal += $drive['size'] ?? 0; + } + + // The drive being reattached is already counted in totalAllocatedStorage (which includes unused drives) + // So we just need to check if the total exceeds the max + if ($this->totalAllocatedStorage > $this->maxAllowedStorage && $this->maxAllowedStorage > 0) { + $this->notify('Storage quota exceeded. Total storage (' . number_format($this->totalAllocatedStorage, 1) . ' GB) exceeds your plan allocation (' . number_format($this->maxAllowedStorage, 1) . ' GB). Please upgrade your service or delete drives to allow this configuration.', 'error'); + return; + } + try { $proxmox = new Proxmox; diff --git a/extensions/Servers/Proxmox/views/storage.blade.php b/extensions/Servers/Proxmox/views/storage.blade.php index 087de373e..76e4727be 100644 --- a/extensions/Servers/Proxmox/views/storage.blade.php +++ b/extensions/Servers/Proxmox/views/storage.blade.php @@ -285,13 +285,22 @@ Device Bus - + @if(count($unusedDrives) >= 2) + + @else + + @endif + @if($totalAllocatedStorage > $maxAllowedStorage && $maxAllowedStorage > 0) + + @else + + @endif