## Summary - move the Laravel application into `apps/platform` and keep the repository root for orchestration, docs, and tooling - update the local command model, Sail/Docker wiring, runtime paths, and ignore rules around the new platform location - add relocation quickstart/contracts plus focused smoke coverage for bootstrap, command model, routes, and runtime behavior ## Validation - `cd apps/platform && ./vendor/bin/sail artisan test --compact tests/Feature/PlatformRelocation` - integrated browser smoke validated `/up`, `/`, `/admin`, `/admin/choose-workspace`, and tenant route semantics for `200`, `403`, and `404` ## Remaining Rollout Checks - validate Dokploy build context and working-directory assumptions against the new `apps/platform` layout - confirm web, queue, and scheduler processes all start from the expected working directory in staging/production - verify no legacy volume mounts or asset-publish paths still point at the old root-level `public/` or `storage/` locations Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #213
105 lines
2.6 KiB
PHP
105 lines
2.6 KiB
PHP
<?php
|
|
|
|
namespace App\Livewire;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Support\OpsUx\ActiveRuns;
|
|
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)
|
|
->healthyActive()
|
|
->orderByDesc('created_at');
|
|
|
|
$activeCount = (clone $query)->count();
|
|
$this->runs = (clone $query)->limit(6)->get();
|
|
$this->overflowCount = max(0, $activeCount - 5);
|
|
$this->hasActiveRuns = ActiveRuns::existForTenantId($tenantId);
|
|
}
|
|
|
|
public function render(): \Illuminate\Contracts\View\View
|
|
{
|
|
return view('livewire.bulk-operation-progress', [
|
|
'tenant' => Filament::getTenant(),
|
|
]);
|
|
}
|
|
}
|