Kurzbeschreibung Implementiert Feature 055 — Ops‑UX Constitution Rollout v1.3.0. Behebt: globales BulkOperationProgress-Widget benötigt keinen manuellen Refresh mehr; ETA/Elapsed aktualisieren korrekt; Widget verschwindet automatisch. Verbesserungen: zuverlässiges polling (Alpine factory + Livewire fallback), sofortiger Enqueue‑Signal-Dispatch, Failure‑Message‑Sanitization, neue Guard‑ und Regressionstests, Specs/Tasks aktualisiert. Was geändert wurde (Auszug) InventoryLanding.php bulk-operation-progress.blade.php OperationUxPresenter.php SyncRestoreRunToOperationRun.php PolicyResource.php PolicyVersionResource.php RestoreRunResource.php tests/Feature/OpsUx/* (PollerRegistration, TerminalNotificationFailureMessageTest, CanonicalViewRunLinksTest, OperationCatalogCoverageTest, UnknownOperationTypeLabelTest) InventorySyncButtonTest.php tasks.md Tests Neue Tests hinzugefügt; php artisan test --group=ops-ux lokal grün (alle relevanten Tests laufen). How to verify manually Auf Branch wechseln: 055-ops-ux-rollout In Filament: Inventory → Sync (oder relevante Bulk‑Aktion) auslösen. Beobachten: Progress‑Widget erscheint sofort, ETA/Elapsed aktualisiert, Widget verschwindet nach Fertigstellung ohne Browser‑Refresh. Optional: ./vendor/bin/sail exec app php artisan test --filter=OpsUx oder php artisan test --group=ops-ux Besonderheiten / Hinweise Einzelne, synchrone Policy‑Actions (ignore/restore/PolicyVersion single archive/restore/forceDelete) sind absichtlich inline und erzeugen kein OperationRun. Bulk‑Aktionen und restore.execute werden als Runs modelliert. Wenn gewünscht, kann ich die inline‑Actions auf OperationRunService umstellen, damit sie in Monitoring → Operations sichtbar werden. Remote: Branch ist bereits gepusht (origin/055-ops-ux-rollout). PR kann in Gitea erstellt werden. Links Specs & tasks: tasks.md Monitoring page: Operations.php Co-authored-by: Ahmed Darrazi <ahmeddarrazi@adsmac.local> Reviewed-on: #64
104 lines
2.5 KiB
PHP
104 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Support\OpsUx\OpsUxBrowserEvents;
|
|
use Filament\Facades\Filament;
|
|
use Illuminate\Support\Collection;
|
|
use Livewire\Attributes\Computed;
|
|
use Livewire\Attributes\On;
|
|
use Livewire\Component;
|
|
|
|
class BulkOperationProgress extends Component
|
|
{
|
|
/**
|
|
* @var Collection<int, OperationRun>
|
|
*/
|
|
public Collection $runs;
|
|
|
|
public int $overflowCount = 0;
|
|
|
|
public bool $disabled = false;
|
|
|
|
public bool $hasActiveRuns = false;
|
|
|
|
public ?int $tenantId = null;
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->runs = collect();
|
|
|
|
$tenant = Filament::getTenant();
|
|
$this->tenantId = $tenant instanceof Tenant ? (int) $tenant->id : null;
|
|
|
|
$this->refreshRuns();
|
|
}
|
|
|
|
#[On(OpsUxBrowserEvents::RunEnqueued)]
|
|
public function onRunEnqueued(?int $tenantId = null): void
|
|
{
|
|
if ($tenantId !== null) {
|
|
$this->tenantId = $tenantId;
|
|
}
|
|
|
|
$this->refreshRuns();
|
|
}
|
|
|
|
#[Computed]
|
|
public function activeRuns()
|
|
{
|
|
return $this->runs;
|
|
}
|
|
|
|
public function refreshRuns(): void
|
|
{
|
|
$tenantId = $this->tenantId;
|
|
|
|
// Best-effort: if we're mounted on a tenant page, capture it once.
|
|
if ($tenantId === null) {
|
|
$tenant = Filament::getTenant();
|
|
$tenantId = $tenant instanceof Tenant ? (int) $tenant->id : null;
|
|
$this->tenantId = $tenantId;
|
|
}
|
|
|
|
if ($tenantId === null) {
|
|
$this->disabled = true;
|
|
$this->runs = collect();
|
|
$this->overflowCount = 0;
|
|
$this->hasActiveRuns = false;
|
|
|
|
return;
|
|
}
|
|
|
|
if (! auth()->user()?->can('viewAny', OperationRun::class)) {
|
|
$this->disabled = true;
|
|
$this->runs = collect();
|
|
$this->overflowCount = 0;
|
|
$this->hasActiveRuns = false;
|
|
|
|
return;
|
|
}
|
|
|
|
$this->disabled = false;
|
|
|
|
$query = OperationRun::query()
|
|
->where('tenant_id', $tenantId)
|
|
->active()
|
|
->orderByDesc('created_at');
|
|
|
|
$activeCount = (clone $query)->count();
|
|
$this->runs = (clone $query)->limit(6)->get();
|
|
$this->overflowCount = max(0, $activeCount - 5);
|
|
$this->hasActiveRuns = $this->runs->isNotEmpty();
|
|
}
|
|
|
|
public function render(): \Illuminate\Contracts\View\View
|
|
{
|
|
return view('livewire.bulk-operation-progress', [
|
|
'tenant' => Filament::getTenant(),
|
|
]);
|
|
}
|
|
}
|