mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 15:44:45 +02:00
Add can check
This commit is contained in:
parent
6c205a744d
commit
329a3993c1
@ -64,9 +64,8 @@ class ListServers extends ListRecords
|
|||||||
->searchable(),
|
->searchable(),
|
||||||
SelectColumn::make('allocation_id')
|
SelectColumn::make('allocation_id')
|
||||||
->label('Primary Allocation')
|
->label('Primary Allocation')
|
||||||
->options(fn (Server $server) => $server->allocations->mapWithKeys(
|
->disabled(fn () => !auth()->user()->can('update server'))
|
||||||
fn ($allocation) => [$allocation->id => $allocation->address])
|
->options(fn (Server $server) => $server->allocations->mapWithKeys(fn ($allocation) => [$allocation->id => $allocation->address]))
|
||||||
)
|
|
||||||
->selectablePlaceholder(false)
|
->selectablePlaceholder(false)
|
||||||
->sortable(),
|
->sortable(),
|
||||||
TextColumn::make('image')->hidden(),
|
TextColumn::make('image')->hidden(),
|
||||||
@ -81,12 +80,7 @@ class ListServers extends ListRecords
|
|||||||
Action::make('View')
|
Action::make('View')
|
||||||
->icon('tabler-terminal')
|
->icon('tabler-terminal')
|
||||||
->url(fn (Server $server) => "/server/$server->uuid_short")
|
->url(fn (Server $server) => "/server/$server->uuid_short")
|
||||||
->visible(function (Server $server) {
|
->visible(fn () => auth()->user()->can('view server')),
|
||||||
/** @var User $user */
|
|
||||||
$user = auth()->user();
|
|
||||||
|
|
||||||
return $user->isRootAdmin() || $user->id === $server->owner_id;
|
|
||||||
}),
|
|
||||||
EditAction::make(),
|
EditAction::make(),
|
||||||
])
|
])
|
||||||
->emptyStateIcon('tabler-brand-docker')
|
->emptyStateIcon('tabler-brand-docker')
|
||||||
|
Loading…
x
Reference in New Issue
Block a user