From 45b73debc23ed2216b943b13b5d8ac45d980aa00 Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Wed, 2 Oct 2024 09:45:03 +0200 Subject: [PATCH] Switch to authorize Co-authored-by: Boy132 --- .../Resources/ServerResource/Pages/ListServers.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Filament/Resources/ServerResource/Pages/ListServers.php b/app/Filament/Resources/ServerResource/Pages/ListServers.php index c94d0edc6..f0ee09a22 100644 --- a/app/Filament/Resources/ServerResource/Pages/ListServers.php +++ b/app/Filament/Resources/ServerResource/Pages/ListServers.php @@ -4,7 +4,6 @@ namespace App\Filament\Resources\ServerResource\Pages; use App\Filament\Resources\ServerResource; use App\Models\Server; -use App\Models\User; use Filament\Actions; use Filament\Resources\Pages\ListRecords; use Filament\Tables\Actions\Action; @@ -64,10 +63,14 @@ class ListServers extends ListRecords ->searchable(), SelectColumn::make('allocation_id') ->label('Primary Allocation') - ->disabled(fn () => !auth()->user()->can('update server')) + ->hidden(!auth()->user()->can('update server')) ->options(fn (Server $server) => $server->allocations->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address])) ->selectablePlaceholder(false) ->sortable(), + TextColumn::make('allocation_id_can') + ->label('Primary Allocation') + ->hidden(auth()->user()->can('update server')) + ->state(fn (Server $server) => $server->allocation->address), TextColumn::make('image')->hidden(), TextColumn::make('backups_count') ->counts('backups') @@ -80,7 +83,7 @@ class ListServers extends ListRecords Action::make('View') ->icon('tabler-terminal') ->url(fn (Server $server) => "/server/$server->uuid_short") - ->visible(fn () => auth()->user()->can('view server')), + ->authorize(fn () => auth()->user()->can('view server')), EditAction::make(), ]) ->emptyStateIcon('tabler-brand-docker')