mirror of
https://github.com/pelican-dev/panel.git
synced 2025-11-09 12:39:30 +01:00
Cleanup
This commit is contained in:
parent
bceb8a057e
commit
42ce06e21c
@ -92,7 +92,7 @@ class DatabaseHostResource extends Resource
|
||||
->checkIfRecordIsSelectableUsing(fn (DatabaseHost $databaseHost) => !$databaseHost->databases_count)
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
])
|
||||
->groupedBulkActions([
|
||||
|
||||
@ -95,7 +95,7 @@ class MountResource extends Resource
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
])
|
||||
->groupedBulkActions([
|
||||
|
||||
@ -98,7 +98,7 @@ class RoleResource extends Resource
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
])
|
||||
->checkIfRecordIsSelectableUsing(fn (Role $role) => !$role->isRootAdmin() && $role->users_count <= 0)
|
||||
|
||||
@ -130,7 +130,7 @@ class UserResource extends Resource
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
])
|
||||
->checkIfRecordIsSelectableUsing(fn (User $user) => user()?->id !== $user->id && !$user->servers_count)
|
||||
|
||||
@ -98,7 +98,7 @@ class WebhookResource extends Resource
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn (WebhookConfiguration $record) => static::canEdit($record)),
|
||||
->hidden(fn (WebhookConfiguration $record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
ReplicateAction::make()
|
||||
->iconButton()
|
||||
|
||||
@ -336,7 +336,7 @@ class ScheduleResource extends Resource
|
||||
])
|
||||
->recordActions([
|
||||
ViewAction::make()
|
||||
->hidden(fn ($record) => static::canEdit($record)),
|
||||
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
|
||||
EditAction::make(),
|
||||
DeleteAction::make()
|
||||
->after(function (Schedule $schedule) {
|
||||
|
||||
@ -4,17 +4,18 @@ namespace App\Policies\Server;
|
||||
|
||||
use App\Models\Permission;
|
||||
use Filament\Facades\Filament;
|
||||
use Illuminate\Database\Eloquent\Model;
|
||||
|
||||
class ActivityLogPolicy
|
||||
{
|
||||
protected string $modelName = 'activityLog';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ACTIVITY_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function view(): bool
|
||||
public function view(Model $model): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ACTIVITY_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -10,22 +10,22 @@ class AllocationPolicy
|
||||
{
|
||||
protected string $modelName = 'allocation';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ALLOCATION_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ALLOCATION_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function edit(Model $record): bool
|
||||
public function edit(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ALLOCATION_UPDATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_ALLOCATION_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -10,17 +10,17 @@ class BackupPolicy
|
||||
{
|
||||
protected string $modelName = 'backup';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_BACKUP_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_BACKUP_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_BACKUP_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -10,27 +10,27 @@ class DatabasePolicy
|
||||
{
|
||||
protected string $modelName = 'database';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_DATABASE_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function view(Model $record): bool
|
||||
public function view(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_DATABASE_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_DATABASE_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function edit(Model $record): bool
|
||||
public function edit(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_DATABASE_UPDATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_DATABASE_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -8,8 +8,10 @@ trait DefaultPolicies
|
||||
* This is a horrendous hack to avoid Laravel's "smart" behavior that does
|
||||
* not call the before() function if there isn't a function matching the
|
||||
* policy permission.
|
||||
*
|
||||
* @param array<string, mixed> $arguments
|
||||
*/
|
||||
public function __call(string $name, mixed $arguments): void
|
||||
public function __call(string $name, array $arguments): void
|
||||
{
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@ -10,22 +10,22 @@ class FilePolicy
|
||||
{
|
||||
protected string $modelName = 'file';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_FILE_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_FILE_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function edit(Model $record): bool
|
||||
public function edit(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_FILE_UPDATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_FILE_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -10,22 +10,22 @@ class SchedulePolicy
|
||||
{
|
||||
protected string $modelName = 'schedule';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_SCHEDULE_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_SCHEDULE_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function edit(Model $record): bool
|
||||
public function edit(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_SCHEDULE_UPDATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_SCHEDULE_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
@ -10,22 +10,22 @@ class UserPolicy
|
||||
{
|
||||
protected string $modelName = 'user';
|
||||
|
||||
public static function viewAny(): bool
|
||||
public function viewAny(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_USER_READ, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function create(): bool
|
||||
public function create(): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_USER_CREATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function edit(Model $record): bool
|
||||
public function edit(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_USER_UPDATE, Filament::getTenant());
|
||||
}
|
||||
|
||||
public static function delete(Model $record): bool
|
||||
public function delete(Model $record): bool
|
||||
{
|
||||
return user()?->can(Permission::ACTION_USER_DELETE, Filament::getTenant());
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user