From 4792542f204e4ddf0459f74571f3f9cb41fd49d4 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 23 Sep 2025 14:56:49 +0200 Subject: [PATCH] Fix refresh action for egg index select & add refresh action to allocation ip selects (#1736) --- .../AllocationsRelationManager.php | 11 ++++++++++- .../Resources/Servers/Pages/CreateServer.php | 11 ++++++++++- .../AllocationsRelationManager.php | 11 ++++++++++- .../Components/Actions/ImportEggAction.php | 15 ++++++++++----- lang/en/admin/node.php | 1 + 5 files changed, 41 insertions(+), 8 deletions(-) diff --git a/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php b/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php index e6c89bc87..9cf1286a1 100644 --- a/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php @@ -85,13 +85,22 @@ class AllocationsRelationManager extends RelationManager ->label(trans('admin/node.create_allocation')) ->schema(fn () => [ Select::make('allocation_ip') - ->options(collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn () => collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) ->label(trans('admin/node.ip_address')) ->inlineLabel() ->ip() ->helperText(trans('admin/node.ip_help')) ->afterStateUpdated(fn (Set $set) => $set('allocation_ports', [])) ->live() + ->hintAction( + Action::make('refresh') + ->iconButton() + ->icon('tabler-refresh') + ->tooltip(trans('admin/node.refresh')) + ->action(function () { + cache()->forget("nodes.{$this->getOwnerRecord()->id}.ips"); + }) + ) ->required(), TextInput::make('allocation_alias') ->label(trans('admin/node.table.alias')) diff --git a/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php b/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php index 7095ac95b..8e208b614 100644 --- a/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php +++ b/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php @@ -218,12 +218,21 @@ class CreateServer extends CreateRecord return [ Select::make('allocation_ip') - ->options(collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn () => collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) ->label(trans('admin/server.ip_address'))->inlineLabel() ->helperText(trans('admin/server.ip_address_helper')) ->afterStateUpdated(fn (Set $set) => $set('allocation_ports', [])) ->ip() ->live() + ->hintAction( + Action::make('refresh') + ->iconButton() + ->icon('tabler-refresh') + ->tooltip(trans('admin/node.refresh')) + ->action(function () use ($get) { + cache()->forget("nodes.{$get('node_id')}.ips"); + }) + ) ->required(), TextInput::make('allocation_alias') ->label(trans('admin/server.alias'))->inlineLabel() diff --git a/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php b/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php index 418ee1744..2a6fbeee0 100644 --- a/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php @@ -77,11 +77,20 @@ class AllocationsRelationManager extends RelationManager ->createAnother(false) ->schema(fn () => [ Select::make('allocation_ip') - ->options(collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn () => collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) ->label(trans('admin/server.ip_address')) ->inlineLabel() ->ip() ->live() + ->hintAction( + Action::make('refresh') + ->iconButton() + ->icon('tabler-refresh') + ->tooltip(trans('admin/node.refresh')) + ->action(function () { + cache()->forget("nodes.{$this->getOwnerRecord()->node->id}.ips"); + }) + ) ->afterStateUpdated(fn (Set $set) => $set('allocation_ports', [])) ->required(), TextInput::make('allocation_alias') diff --git a/app/Filament/Components/Actions/ImportEggAction.php b/app/Filament/Components/Actions/ImportEggAction.php index c20635f28..77a156d57 100644 --- a/app/Filament/Components/Actions/ImportEggAction.php +++ b/app/Filament/Components/Actions/ImportEggAction.php @@ -125,15 +125,20 @@ class ImportEggAction extends Action ->schema([ Select::make('github') ->label(trans('admin/egg.import.github')) - ->options(cache('eggs.index')) + ->options(fn () => cache('eggs.index')) ->selectablePlaceholder(false) ->searchable() ->preload() ->live() - ->hintIcon('tabler-refresh', trans('admin/egg.import.refresh')) - ->hintAction(function () { - Artisan::call(UpdateEggIndexCommand::class); - }) + ->hintAction( + Action::make('refresh') + ->iconButton() + ->icon('tabler-refresh') + ->tooltip(trans('admin/egg.import.refresh')) + ->action(function () { + Artisan::call(UpdateEggIndexCommand::class); + }) + ) ->afterStateUpdated(function ($state, Set $set, Get $get) use ($isMultiple) { if ($state) { $urls = $isMultiple ? $get('urls') : []; diff --git a/lang/en/admin/node.php b/lang/en/admin/node.php index 01922d93d..a726300ee 100644 --- a/lang/en/admin/node.php +++ b/lang/en/admin/node.php @@ -37,6 +37,7 @@ return [ 'ip_address' => 'IP Address', 'ip_help' => 'Usually your machine\'s public IP unless you are port forwarding.', 'alias_help' => 'Optional display name to help you remember what these are.', + 'refresh' => 'Refresh', 'domain' => 'Domain Name', 'ssl_ip' => 'You cannot connect to an IP Address over SSL', 'error' => 'This is the domain name that points to your node\'s IP Address. If you\'ve already set up this, you can verify it by checking the next field!',