modifyQueryUsing(fn (Builder $query) => $query->where('tenant_id', Tenant::currentOrFail()->getKey())) ->defaultSort('created_at', 'desc') ->columns([ Tables\Columns\TextColumn::make('created_at') ->label('Enqueued') ->dateTime(), Tables\Columns\TextColumn::make('type') ->label('Type') ->formatStateUsing(fn (string $state): string => OperationCatalog::label($state)), Tables\Columns\TextColumn::make('status') ->badge() ->formatStateUsing(BadgeRenderer::label(BadgeDomain::OperationRunStatus)) ->color(BadgeRenderer::color(BadgeDomain::OperationRunStatus)) ->icon(BadgeRenderer::icon(BadgeDomain::OperationRunStatus)) ->iconColor(BadgeRenderer::iconColor(BadgeDomain::OperationRunStatus)), Tables\Columns\TextColumn::make('outcome') ->badge() ->formatStateUsing(BadgeRenderer::label(BadgeDomain::OperationRunOutcome)) ->color(BadgeRenderer::color(BadgeDomain::OperationRunOutcome)) ->icon(BadgeRenderer::icon(BadgeDomain::OperationRunOutcome)) ->iconColor(BadgeRenderer::iconColor(BadgeDomain::OperationRunOutcome)), Tables\Columns\TextColumn::make('counts') ->label('Counts') ->getStateUsing(function (OperationRun $record): string { $counts = is_array($record->summary_counts) ? $record->summary_counts : []; $total = (int) ($counts['total'] ?? 0); $succeeded = (int) ($counts['succeeded'] ?? 0); $failed = (int) ($counts['failed'] ?? 0); if ($total === 0 && $succeeded === 0 && $failed === 0) { return '—'; } return sprintf('%d/%d (%d failed)', $succeeded, $total, $failed); }), ]) ->filters([]) ->headerActions([]) ->actions([ Actions\Action::make('view') ->label('View') ->icon('heroicon-o-eye') ->url(function (OperationRun $record): string { $tenant = Tenant::currentOrFail(); return OperationRunLinks::view($record, $tenant); }) ->openUrlInNewTab(true), ]) ->bulkActions([]); } }