fix(spec-077): link to tenant-scoped operation details
This commit is contained in:
parent
572201457d
commit
b07313cfe1
@ -5,8 +5,10 @@
|
|||||||
namespace App\Filament\Pages\Operations;
|
namespace App\Filament\Pages\Operations;
|
||||||
|
|
||||||
use App\Models\OperationRun;
|
use App\Models\OperationRun;
|
||||||
|
use App\Models\Tenant;
|
||||||
use App\Models\User;
|
use App\Models\User;
|
||||||
use App\Models\WorkspaceMembership;
|
use App\Models\WorkspaceMembership;
|
||||||
|
use App\Services\Auth\CapabilityResolver;
|
||||||
use Filament\Actions\Action;
|
use Filament\Actions\Action;
|
||||||
use Filament\Pages\Page;
|
use Filament\Pages\Page;
|
||||||
|
|
||||||
@ -29,13 +31,39 @@ class TenantlessOperationRunViewer extends Page
|
|||||||
*/
|
*/
|
||||||
protected function getHeaderActions(): array
|
protected function getHeaderActions(): array
|
||||||
{
|
{
|
||||||
return [
|
$actions = [
|
||||||
Action::make('refresh')
|
Action::make('refresh')
|
||||||
->label('Refresh')
|
->label('Refresh')
|
||||||
->icon('heroicon-o-arrow-path')
|
->icon('heroicon-o-arrow-path')
|
||||||
->color('gray')
|
->color('gray')
|
||||||
->url(fn (): string => url()->current()),
|
->url(fn (): string => url()->current()),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
if (! isset($this->run)) {
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
$tenant = $this->run->tenant;
|
||||||
|
$user = auth()->user();
|
||||||
|
|
||||||
|
if (! $tenant instanceof Tenant || ! $user instanceof User) {
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (! app(CapabilityResolver::class)->isMember($user, $tenant)) {
|
||||||
|
return $actions;
|
||||||
|
}
|
||||||
|
|
||||||
|
$actions[] = Action::make('admin_details')
|
||||||
|
->label('Admin details')
|
||||||
|
->icon('heroicon-o-arrow-top-right-on-square')
|
||||||
|
->color('gray')
|
||||||
|
->url(fn (): string => route('filament.admin.resources.operations.view', [
|
||||||
|
'tenant' => (int) $tenant->getKey(),
|
||||||
|
'record' => (int) $this->run->getKey(),
|
||||||
|
]));
|
||||||
|
|
||||||
|
return $actions;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mount(OperationRun $run): void
|
public function mount(OperationRun $run): void
|
||||||
|
|||||||
@ -67,7 +67,8 @@
|
|||||||
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
|
->withSession([WorkspaceContext::SESSION_KEY => (int) $tenant->workspace_id])
|
||||||
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
|
->get(route('admin.operations.view', ['run' => (int) $run->getKey()]))
|
||||||
->assertOk()
|
->assertOk()
|
||||||
->assertSee('Operation run');
|
->assertSee('Operation run')
|
||||||
|
->assertSee('/admin/t/'.((int) $tenant->getKey()).'/operations/r/'.((int) $run->getKey()));
|
||||||
|
|
||||||
Filament::setTenant($tenant, true);
|
Filament::setTenant($tenant, true);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user