user(); if (! $user instanceof PlatformUser) { return false; } return $user->hasCapability(PlatformCapabilities::OPERATIONS_VIEW) || ($user->hasCapability(PlatformCapabilities::OPS_VIEW) && $user->hasCapability(PlatformCapabilities::RUNBOOKS_VIEW)); } public function mount(OperationRun $run): void { $run->load(['tenant', 'workspace']); $this->run = $run; } /** * @return array */ protected function getHeaderActions(): array { return [ Action::make('go_to_runbooks') ->label('Go to runbooks') ->url(Runbooks::getUrl(panel: 'system')), Action::make('retry') ->label('Retry') ->requiresConfirmation() ->visible(fn (): bool => $this->canManageOperations() && app(OperationRunTriageService::class)->canRetry($this->run)) ->action(function (OperationRunTriageService $triageService): void { $user = $this->requireManageUser(); $retryRun = $triageService->retry($this->run, $user); OperationUxPresenter::queuedToast((string) $retryRun->type) ->actions([ \Filament\Actions\Action::make('view_run') ->label('View run') ->url(SystemOperationRunLinks::view($retryRun)), ]) ->send(); }), Action::make('cancel') ->label('Cancel') ->color('danger') ->requiresConfirmation() ->visible(fn (): bool => $this->canManageOperations() && app(OperationRunTriageService::class)->canCancel($this->run)) ->action(function (OperationRunTriageService $triageService): void { $user = $this->requireManageUser(); $triageService->cancel($this->run, $user); Notification::make() ->title('Run cancelled') ->success() ->send(); }), Action::make('mark_investigated') ->label('Mark investigated') ->requiresConfirmation() ->visible(fn (): bool => $this->canManageOperations()) ->form([ Textarea::make('reason') ->label('Reason') ->required() ->minLength(5) ->maxLength(500) ->rows(4), ]) ->action(function (array $data, OperationRunTriageService $triageService): void { $user = $this->requireManageUser(); $triageService->markInvestigated($this->run, $user, (string) ($data['reason'] ?? '')); Notification::make() ->title('Run marked as investigated') ->success() ->send(); }), ]; } private function canManageOperations(): bool { $user = auth('platform')->user(); return $user instanceof PlatformUser && $user->hasCapability(PlatformCapabilities::OPERATIONS_MANAGE); } private function requireManageUser(): PlatformUser { $user = auth('platform')->user(); if (! $user instanceof PlatformUser || ! $user->hasCapability(PlatformCapabilities::OPERATIONS_MANAGE)) { abort(403); } return $user; } }