From 6a50f7bef3933b8e2bcf7b8fc9a4afa19107b9b2 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 09:13:59 +0100 Subject: [PATCH 1/8] add placeholder to allocation notes --- .../Resources/AllocationResource/Pages/ListAllocations.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Filament/Server/Resources/AllocationResource/Pages/ListAllocations.php b/app/Filament/Server/Resources/AllocationResource/Pages/ListAllocations.php index 0ca5154048..a7ed76d99b 100644 --- a/app/Filament/Server/Resources/AllocationResource/Pages/ListAllocations.php +++ b/app/Filament/Server/Resources/AllocationResource/Pages/ListAllocations.php @@ -36,7 +36,8 @@ public function table(Table $table): Table TextColumn::make('port'), TextInputColumn::make('notes') ->disabled(fn () => !auth()->user()->can(Permission::ACTION_ALLOCATION_UPDATE, $server)) - ->label('Notes'), + ->label('Notes') + ->placeholder('No Notes'), IconColumn::make('primary') ->icon(fn ($state) => match ($state) { true => 'tabler-star-filled', From e07f579854ea0e26dededa3ca6b1df2d4c46d016 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 09:21:16 +0100 Subject: [PATCH 2/8] add button to open server in admin area --- app/Providers/Filament/ServerPanelProvider.php | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/app/Providers/Filament/ServerPanelProvider.php b/app/Providers/Filament/ServerPanelProvider.php index f1b946f18c..e9c29a75ff 100644 --- a/app/Providers/Filament/ServerPanelProvider.php +++ b/app/Providers/Filament/ServerPanelProvider.php @@ -4,6 +4,7 @@ use App\Filament\App\Resources\ServerResource\Pages\ListServers; use App\Filament\Pages\Auth\Login; +use App\Filament\Resources\ServerResource\Pages\EditServer; use App\Filament\Resources\UserResource\Pages\EditProfile; use App\Http\Middleware\Activity\ServerSubject; use App\Models\Server; @@ -12,6 +13,7 @@ use Filament\Http\Middleware\DisableBladeIconComponents; use Filament\Http\Middleware\DispatchServingFilamentEvent; use Filament\Navigation\MenuItem; +use Filament\Navigation\NavigationItem; use Filament\Panel; use Filament\PanelProvider; use Filament\Support\Enums\MaxWidth; @@ -54,6 +56,13 @@ public function panel(Panel $panel): Panel ->sort(5) ->visible(fn (): bool => auth()->user()->canAccessPanel(Filament::getPanel('admin'))), ]) + ->navigationItems([ + NavigationItem::make('Open in Admin') + ->url(fn () => EditServer::getUrl(['record' => Filament::getTenant()], panel: 'admin', tenant: null), true) + ->visible(fn () => auth()->user()->can('view server'), Filament::getTenant()) + ->icon('tabler-logout-2') + ->sort(99), + ]) ->discoverResources(in: app_path('Filament/Server/Resources'), for: 'App\\Filament\\Server\\Resources') ->discoverPages(in: app_path('Filament/Server/Pages'), for: 'App\\Filament\\Server\\Pages') ->discoverWidgets(in: app_path('Filament/Server/Widgets'), for: 'App\\Filament\\Server\\Widgets') From b8edc27e35a73310ab349f30288fabed12cf33db Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 09:23:08 +0100 Subject: [PATCH 3/8] use new client area for "console" button on EditServer --- app/Filament/Resources/ServerResource/Pages/EditServer.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Filament/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Resources/ServerResource/Pages/EditServer.php index 172c1ebf45..126d098e7f 100644 --- a/app/Filament/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Resources/ServerResource/Pages/EditServer.php @@ -6,6 +6,7 @@ use App\Enums\ServerState; use App\Filament\Resources\ServerResource; use App\Filament\Resources\ServerResource\RelationManagers\AllocationsRelationManager; +use App\Filament\Server\Pages\Console; use App\Models\Database; use App\Models\DatabaseHost; use App\Models\Egg; @@ -870,7 +871,7 @@ protected function getHeaderActions(): array Actions\Action::make('console') ->label('Console') ->icon('tabler-terminal') - ->url(fn (Server $server) => "/server/$server->uuid_short"), + ->url(fn (Server $server) => Console::getUrl(panel: 'server', tenant: $server)), $this->getSaveFormAction()->formId('form'), ]; From f1a5e62ae96d0927367c7f989c8bf7b9a9273026 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 09:28:38 +0100 Subject: [PATCH 4/8] hide schedule presets on view --- app/Filament/Server/Resources/ScheduleResource.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Filament/Server/Resources/ScheduleResource.php b/app/Filament/Server/Resources/ScheduleResource.php index 470fc5ada8..5cec5f2750 100644 --- a/app/Filament/Server/Resources/ScheduleResource.php +++ b/app/Filament/Server/Resources/ScheduleResource.php @@ -111,6 +111,7 @@ public static function form(Form $form): Form ->default('*') ->required(), Section::make('Presets') + ->hiddenOn('view') ->schema([ Actions::make([ Action::make('hourly') From c23999be13ae076d3ef851bdbe0468304d7fe727 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 14:24:43 +0100 Subject: [PATCH 5/8] use arrow functions for auth checks --- app/Filament/Server/Pages/Settings.php | 6 +++--- app/Filament/Server/Pages/Startup.php | 4 ++-- .../Server/Resources/FileResource/Pages/EditFiles.php | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/Filament/Server/Pages/Settings.php b/app/Filament/Server/Pages/Settings.php index c4d01a09f5..758676fe35 100644 --- a/app/Filament/Server/Pages/Settings.php +++ b/app/Filament/Server/Pages/Settings.php @@ -53,7 +53,7 @@ public function form(Form $form): Form ->schema([ TextInput::make('name') ->label('Server Name') - ->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server)) + ->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server)) ->required() ->columnSpan([ 'default' => 1, @@ -66,7 +66,7 @@ public function form(Form $form): Form Textarea::make('description') ->label('Server Description') ->hidden(!config('panel.editable_server_descriptions')) - ->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server)) + ->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_RENAME, $server)) ->columnSpan([ 'default' => 1, 'sm' => 2, @@ -168,7 +168,7 @@ public function form(Form $form): Form ->footerActions([ Action::make('reinstall') ->color('danger') - ->disabled(!auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server)) + ->disabled(fn () => !auth()->user()->can(Permission::ACTION_SETTINGS_REINSTALL, $server)) ->label('Reinstall') ->requiresConfirmation() ->modalHeading('Are you sure you want to reinstall the server?') diff --git a/app/Filament/Server/Pages/Startup.php b/app/Filament/Server/Pages/Startup.php index 943a9a4d9b..4aa8dd0de5 100644 --- a/app/Filament/Server/Pages/Startup.php +++ b/app/Filament/Server/Pages/Startup.php @@ -62,7 +62,7 @@ public function form(Form $form): Form ->label('Docker Image') ->live() ->visible(fn (Server $server) => in_array($server->image, $server->egg->docker_images)) - ->disabled(!auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server)) + ->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_DOCKER_IMAGE, $server)) ->afterStateUpdated(function ($state, Server $server) { $original = $server->image; $server->forceFill(['image' => $state])->saveOrFail(); @@ -97,7 +97,7 @@ public function form(Form $form): Form ->label('') ->relationship('viewableServerVariables') ->grid() - ->disabled(!auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server)) + ->disabled(fn () => !auth()->user()->can(Permission::ACTION_STARTUP_UPDATE, $server)) ->reorderable(false)->addable(false)->deletable(false) ->schema(function () { $text = TextInput::make('variable_value') diff --git a/app/Filament/Server/Resources/FileResource/Pages/EditFiles.php b/app/Filament/Server/Resources/FileResource/Pages/EditFiles.php index 2d7b9a8629..b6c2cd440b 100644 --- a/app/Filament/Server/Resources/FileResource/Pages/EditFiles.php +++ b/app/Filament/Server/Resources/FileResource/Pages/EditFiles.php @@ -70,7 +70,7 @@ public function form(Form $form): Form ->footerActions([ Action::make('save') ->label('Save Changes') - ->authorize(auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server)) + ->authorize(fn () => auth()->user()->can(Permission::ACTION_FILE_UPDATE, $server)) ->icon('tabler-device-floppy') ->keyBindings('mod+s') ->action(function () use ($server) { From 56643201e8ba2f29a42ddd0aead9b60486e46321 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 14:31:32 +0100 Subject: [PATCH 6/8] add placeholder to schedules last run --- .../Server/Resources/ScheduleResource/Pages/ListSchedules.php | 1 + 1 file changed, 1 insertion(+) diff --git a/app/Filament/Server/Resources/ScheduleResource/Pages/ListSchedules.php b/app/Filament/Server/Resources/ScheduleResource/Pages/ListSchedules.php index 4f53bb3d8b..078488158b 100644 --- a/app/Filament/Server/Resources/ScheduleResource/Pages/ListSchedules.php +++ b/app/Filament/Server/Resources/ScheduleResource/Pages/ListSchedules.php @@ -33,6 +33,7 @@ public function table(Table $table): Table ->sortable(), DateTimeColumn::make('last_run_at') ->label('Last run') + ->placeholder('Never') ->since() ->sortable(), DateTimeColumn::make('next_run_at') From 60a5ac040d7d1d85b5ffb256c821e586cc501cca Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 14:35:01 +0100 Subject: [PATCH 7/8] change icon of "open in admin" --- app/Providers/Filament/ServerPanelProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/Filament/ServerPanelProvider.php b/app/Providers/Filament/ServerPanelProvider.php index e9c29a75ff..fdba147a10 100644 --- a/app/Providers/Filament/ServerPanelProvider.php +++ b/app/Providers/Filament/ServerPanelProvider.php @@ -60,7 +60,7 @@ public function panel(Panel $panel): Panel NavigationItem::make('Open in Admin') ->url(fn () => EditServer::getUrl(['record' => Filament::getTenant()], panel: 'admin', tenant: null), true) ->visible(fn () => auth()->user()->can('view server'), Filament::getTenant()) - ->icon('tabler-logout-2') + ->icon('tabler-arrow-back') ->sort(99), ]) ->discoverResources(in: app_path('Filament/Server/Resources'), for: 'App\\Filament\\Server\\Resources') From 10b298932dfb5ffbfb17dcd7b9b1101e1b36bf5f Mon Sep 17 00:00:00 2001 From: Boy132 Date: Mon, 2 Dec 2024 14:42:12 +0100 Subject: [PATCH 8/8] fix parentheses --- app/Providers/Filament/ServerPanelProvider.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Providers/Filament/ServerPanelProvider.php b/app/Providers/Filament/ServerPanelProvider.php index fdba147a10..af815a89b3 100644 --- a/app/Providers/Filament/ServerPanelProvider.php +++ b/app/Providers/Filament/ServerPanelProvider.php @@ -59,7 +59,7 @@ public function panel(Panel $panel): Panel ->navigationItems([ NavigationItem::make('Open in Admin') ->url(fn () => EditServer::getUrl(['record' => Filament::getTenant()], panel: 'admin', tenant: null), true) - ->visible(fn () => auth()->user()->can('view server'), Filament::getTenant()) + ->visible(fn () => auth()->user()->can('view server', Filament::getTenant())) ->icon('tabler-arrow-back') ->sort(99), ])