## Summary - align operator-visible OperationRun terminology to canonical `Operations` / `Operation` labels across shared links, notifications, verification/onboarding surfaces, summary widgets, and monitoring/detail pages - add the Spec 171 planning artifacts under `specs/171-operations-naming-consolidation/` - close the remaining tenant dashboard and admin copy drift found during browser smoke validation ## Validation - `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Unit/Support/RelatedNavigationResolverTest.php tests/Unit/Support/References/RelatedContextReferenceAdapterTest.php tests/Feature/OpsUx/NotificationViewRunLinkTest.php tests/Feature/Guards/ActionSurfaceContractTest.php tests/Feature/Operations/TenantlessOperationRunViewerTest.php tests/Feature/Filament/BackupSetResolvedReferencePresentationTest.php tests/Feature/Filament/TenantVerificationReportWidgetTest.php tests/Feature/Onboarding/OnboardingVerificationTest.php tests/Feature/Onboarding/OnboardingVerificationClustersTest.php tests/Feature/Onboarding/OnboardingVerificationV1_5UxTest.php tests/Feature/Filament/BaselineCompareSummaryConsistencyTest.php tests/Feature/Filament/WorkspaceOverviewContentTest.php tests/Feature/Filament/RecentOperationsSummaryWidgetTest.php tests/Feature/Monitoring/OperationLifecycleAggregateVisibilityTest.php tests/Feature/System/Spec114/OpsTriageActionsTest.php tests/Feature/System/Spec114/OpsFailuresViewTest.php tests/Feature/System/Spec114/OpsStuckViewTest.php` - `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail artisan test --compact tests/Browser/OnboardingDraftRefreshTest.php` - `export PATH="/bin:/usr/bin:/usr/local/bin:$PATH" && vendor/bin/sail bin pint --dirty --format agent` ## Notes - no schema or route renames - Filament / Livewire surface behavior stays within the existing admin and tenant panels - OperationRunResource remains excluded from global search Co-authored-by: Ahmed Darrazi <ahmed.darrazi@live.de> Reviewed-on: #202
88 lines
3.7 KiB
PHP
88 lines
3.7 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Filament\Widgets\Dashboard;
|
|
|
|
use App\Models\OperationRun;
|
|
use App\Models\Tenant;
|
|
use App\Support\Badges\BadgeDomain;
|
|
use App\Support\Badges\BadgeRenderer;
|
|
use App\Support\OperationCatalog;
|
|
use App\Support\OperationRunLinks;
|
|
use App\Support\OpsUx\ActiveRuns;
|
|
use App\Support\OpsUx\OperationUxPresenter;
|
|
use Filament\Facades\Filament;
|
|
use Filament\Tables\Columns\TextColumn;
|
|
use Filament\Tables\Table;
|
|
use Filament\Widgets\TableWidget;
|
|
use Illuminate\Database\Eloquent\Builder;
|
|
|
|
class RecentOperations extends TableWidget
|
|
{
|
|
protected int|string|array $columnSpan = 'full';
|
|
|
|
public function table(Table $table): Table
|
|
{
|
|
$tenant = Filament::getTenant();
|
|
|
|
return $table
|
|
->heading('Recent Operations')
|
|
->query($this->getQuery())
|
|
->poll(fn (): ?string => ($tenant instanceof Tenant) && ActiveRuns::existForTenant($tenant) ? '10s' : null)
|
|
->defaultSort('created_at', 'desc')
|
|
->paginated(\App\Support\Filament\TablePaginationProfiles::widget())
|
|
->columns([
|
|
TextColumn::make('short_id')
|
|
->label(OperationRunLinks::identifierLabel())
|
|
->state(fn (OperationRun $record): string => OperationRunLinks::identifier($record))
|
|
->copyable()
|
|
->copyableState(fn (OperationRun $record): string => (string) $record->getKey()),
|
|
TextColumn::make('type')
|
|
->label('Operation')
|
|
->sortable()
|
|
->formatStateUsing(fn (?string $state): string => OperationCatalog::label((string) $state))
|
|
->limit(40)
|
|
->tooltip(fn (OperationRun $record): string => OperationCatalog::label((string) $record->type)),
|
|
TextColumn::make('status')
|
|
->badge()
|
|
->sortable()
|
|
->toggleable(isToggledHiddenByDefault: true)
|
|
->formatStateUsing(BadgeRenderer::label(BadgeDomain::OperationRunStatus))
|
|
->color(BadgeRenderer::color(BadgeDomain::OperationRunStatus))
|
|
->icon(BadgeRenderer::icon(BadgeDomain::OperationRunStatus))
|
|
->iconColor(BadgeRenderer::iconColor(BadgeDomain::OperationRunStatus)),
|
|
TextColumn::make('outcome')
|
|
->badge()
|
|
->sortable()
|
|
->formatStateUsing(BadgeRenderer::label(BadgeDomain::OperationRunOutcome))
|
|
->color(BadgeRenderer::color(BadgeDomain::OperationRunOutcome))
|
|
->icon(BadgeRenderer::icon(BadgeDomain::OperationRunOutcome))
|
|
->iconColor(BadgeRenderer::iconColor(BadgeDomain::OperationRunOutcome))
|
|
->description(fn (OperationRun $record): ?string => OperationUxPresenter::surfaceGuidance($record)),
|
|
TextColumn::make('created_at')
|
|
->label('Started')
|
|
->sortable()
|
|
->since(),
|
|
])
|
|
->recordUrl(fn (OperationRun $record): ?string => $tenant instanceof Tenant
|
|
? OperationRunLinks::view($record, $tenant)
|
|
: null)
|
|
->emptyStateHeading('No operations yet')
|
|
->emptyStateDescription('Once you run inventory sync, drift generation, or restores, they\'ll show up here.');
|
|
}
|
|
|
|
/**
|
|
* @return Builder<OperationRun>
|
|
*/
|
|
private function getQuery(): Builder
|
|
{
|
|
$tenant = Filament::getTenant();
|
|
$tenantId = $tenant instanceof Tenant ? $tenant->getKey() : null;
|
|
|
|
return OperationRun::query()
|
|
->when($tenantId, fn (Builder $query) => $query->where('tenant_id', $tenantId))
|
|
->latest('created_at');
|
|
}
|
|
}
|