feat(storages): add method to retrieve the first storage ID for improved stability in storage display
This commit is contained in:
@@ -9,4 +9,15 @@ class All extends Component
|
|||||||
public $resource;
|
public $resource;
|
||||||
|
|
||||||
protected $listeners = ['refreshStorages' => '$refresh'];
|
protected $listeners = ['refreshStorages' => '$refresh'];
|
||||||
|
|
||||||
|
public function getFirstStorageIdProperty()
|
||||||
|
{
|
||||||
|
if ($this->resource->persistentStorages->isEmpty()) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use the storage with the smallest ID as the "first" one
|
||||||
|
// This ensures stability even when storages are deleted
|
||||||
|
return $this->resource->persistentStorages->sortBy('id')->first()->id;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -3,10 +3,10 @@
|
|||||||
@foreach ($resource->persistentStorages as $storage)
|
@foreach ($resource->persistentStorages as $storage)
|
||||||
@if ($resource->type() === 'service')
|
@if ($resource->type() === 'service')
|
||||||
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
|
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
|
||||||
:resource="$resource" :isFirst="$loop->first" isService='true' />
|
:resource="$resource" :isFirst="$storage->id === $this->firstStorageId" isService='true' />
|
||||||
@else
|
@else
|
||||||
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
|
<livewire:project.shared.storages.show wire:key="storage-{{ $storage->id }}" :storage="$storage"
|
||||||
:resource="$resource" startedAt="{{ data_get($resource, 'started_at') }}" />
|
:resource="$resource" :isFirst="$storage->id === $this->firstStorageId" startedAt="{{ data_get($resource, 'started_at') }}" />
|
||||||
@endif
|
@endif
|
||||||
@endforeach
|
@endforeach
|
||||||
</div>
|
</div>
|
||||||
|
Reference in New Issue
Block a user