From 6e53b1cd7df5a46d00aaca161f5cc4d6ddf8acd1 Mon Sep 17 00:00:00 2001 From: Lance Pioch Date: Thu, 12 Feb 2026 09:49:54 -0500 Subject: [PATCH] Allow custom ips to still be entered (#2223) --- .../AllocationsRelationManager.php | 17 ++++++++++++++++- .../Resources/Servers/Pages/CreateServer.php | 17 ++++++++++++++++- .../AllocationsRelationManager.php | 17 ++++++++++++++++- lang/en/admin/node.php | 1 + 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php b/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php index 2ddeaf841..e6344d29a 100644 --- a/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Admin/Resources/Nodes/RelationManagers/AllocationsRelationManager.php @@ -91,7 +91,10 @@ class AllocationsRelationManager extends RelationManager ->icon(TablerIcon::WorldPlus) ->schema(fn () => [ Select::make('allocation_ip') - ->options(fn () => collect($this->getOwnerRecord()->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn (Get $get) => collect($this->getOwnerRecord()->ipAddresses()) + ->when($get('allocation_ip'), fn ($ips, $current) => $ips->push($current)) + ->unique() + ->mapWithKeys(fn (string $ip) => [$ip => $ip])) ->label(trans('admin/node.ip_address')) ->inlineLabel() ->ip() @@ -106,6 +109,18 @@ class AllocationsRelationManager extends RelationManager cache()->forget("nodes.{$this->getOwnerRecord()->id}.ips"); }) ) + ->suffixAction( + Action::make('custom_ip') + ->icon(TablerIcon::Keyboard) + ->tooltip(trans('admin/node.custom_ip')) + ->schema([ + TextInput::make('custom_ip') + ->label(trans('admin/node.ip_address')) + ->ip() + ->required(), + ]) + ->action(fn (array $data, Set $set) => $set('allocation_ip', $data['custom_ip'])) + ) ->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 20f4748c9..a47935832 100644 --- a/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php +++ b/app/Filament/Admin/Resources/Servers/Pages/CreateServer.php @@ -251,7 +251,10 @@ class CreateServer extends CreateRecord return [ Select::make('allocation_ip') - ->options(fn () => collect(Node::find($get('node_id'))?->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn (Get $get) => collect(Node::find($getPage('node_id'))?->ipAddresses()) + ->when($get('allocation_ip'), fn ($ips, $current) => $ips->push($current)) + ->unique() + ->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', [])) @@ -266,6 +269,18 @@ class CreateServer extends CreateRecord cache()->forget("nodes.{$get('node_id')}.ips"); }) ) + ->suffixAction( + Action::make('custom_ip') + ->icon(TablerIcon::Keyboard) + ->tooltip(trans('admin/node.custom_ip')) + ->schema([ + TextInput::make('custom_ip') + ->label(trans('admin/node.ip_address')) + ->ip() + ->required(), + ]) + ->action(fn (array $data, Set $set) => $set('allocation_ip', $data['custom_ip'])) + ) ->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 57f7d1dbc..01d8a6525 100644 --- a/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php +++ b/app/Filament/Admin/Resources/Servers/RelationManagers/AllocationsRelationManager.php @@ -113,7 +113,10 @@ class AllocationsRelationManager extends RelationManager ->createAnother(false) ->schema(fn () => [ Select::make('allocation_ip') - ->options(fn () => collect($this->getOwnerRecord()->node->ipAddresses())->mapWithKeys(fn (string $ip) => [$ip => $ip])) + ->options(fn (Get $get) => collect($this->getOwnerRecord()->node->ipAddresses()) + ->when($get('allocation_ip'), fn ($ips, $current) => $ips->push($current)) + ->unique() + ->mapWithKeys(fn (string $ip) => [$ip => $ip])) ->label(trans('admin/server.ip_address')) ->inlineLabel() ->ip() @@ -126,6 +129,18 @@ class AllocationsRelationManager extends RelationManager cache()->forget("nodes.{$this->getOwnerRecord()->node->id}.ips"); }) ) + ->suffixAction( + Action::make('custom_ip') + ->icon(TablerIcon::Keyboard) + ->tooltip(trans('admin/node.custom_ip')) + ->schema([ + TextInput::make('custom_ip') + ->label(trans('admin/node.ip_address')) + ->ip() + ->required(), + ]) + ->action(fn (array $data, Set $set) => $set('allocation_ip', $data['custom_ip'])) + ) ->afterStateUpdated(fn (Set $set) => $set('allocation_ports', [])) ->required(), TextInput::make('allocation_alias') diff --git a/lang/en/admin/node.php b/lang/en/admin/node.php index 60ddd45a8..62d1311cd 100644 --- a/lang/en/admin/node.php +++ b/lang/en/admin/node.php @@ -39,6 +39,7 @@ return [ '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', + 'custom_ip' => 'Enter Custom IP', '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!',