feat: prevent moving drive to the same bus type and update UI to reflect current bus status

This commit is contained in:
2025-12-05 05:56:13 -05:00
parent 48f752c0f6
commit f40b53e301
2 changed files with 10 additions and 2 deletions

View File

@@ -831,6 +831,12 @@ class Storage extends Component
$drive = $this->drives[$this->movingDriveKey];
$targetBus = $this->moveDriveTargetBus;
// Prevent moving to the same bus type
if ($drive['bus'] === $targetBus) {
$this->notify('Drive is already on the ' . $this->busTypes[$targetBus]['label'] . ' bus.', 'error');
return;
}
// Get next available index on target bus
$targetIndex = $this->getNextAvailableIndex($targetBus);
if ($targetIndex === null) {

View File

@@ -619,7 +619,9 @@
<select wire:model="moveDriveTargetBus"
class="w-full px-3 py-2 text-sm rounded-lg border border-neutral bg-background focus:border-primary focus:ring-1 focus:ring-primary transition-colors">
@foreach($busTypes as $busKey => $busConfig)
<option value="{{ $busKey }}">{{ $busConfig['label'] }}</option>
<option value="{{ $busKey }}" @if($moveDrive['bus'] === $busKey) disabled @endif>
{{ $busConfig['label'] }} @if($moveDrive['bus'] === $busKey) (Current) @endif
</option>
@endforeach
</select>
</div>
@@ -640,7 +642,7 @@
<button wire:click="moveDrive"
wire:loading.attr="disabled"
class="px-4 py-2 text-sm font-medium rounded-lg bg-primary text-white hover:bg-primary/90 disabled:opacity-50 transition-colors"
@if($status && $status->status !== 'stopped') disabled @endif>
@if(($status && $status->status !== 'stopped') || $moveDrive['bus'] === $moveDriveTargetBus) disabled @endif>
<x-loading target="moveDrive" />
<span wire:loading.remove wire:target="moveDrive">Change Bus</span>
<span wire:loading wire:target="moveDrive">Changing...</span>