Fix allocations by admins aren't locked by default (#1879)

This commit is contained in:
Boy132 2025-11-09 18:29:46 +01:00 committed by GitHub
parent f4ee33fa4f
commit 5c3b0919aa
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 0 deletions

View File

@ -11,6 +11,7 @@ use Filament\Actions\AssociateAction;
use Filament\Actions\CreateAction; use Filament\Actions\CreateAction;
use Filament\Actions\DissociateAction; use Filament\Actions\DissociateAction;
use Filament\Actions\DissociateBulkAction; use Filament\Actions\DissociateBulkAction;
use Filament\Forms\Components\Hidden;
use Filament\Forms\Components\Select; use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput; use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput; use Filament\Forms\Components\TextInput;
@ -126,6 +127,8 @@ class AllocationsRelationManager extends RelationManager
->afterStateUpdated(fn ($state, Set $set, Get $get) => $set('allocation_ports', CreateServer::retrieveValidPorts($this->getOwnerRecord()->node, $state, $get('allocation_ip')))) ->afterStateUpdated(fn ($state, Set $set, Get $get) => $set('allocation_ports', CreateServer::retrieveValidPorts($this->getOwnerRecord()->node, $state, $get('allocation_ip'))))
->splitKeys(['Tab', ' ', ',']) ->splitKeys(['Tab', ' ', ','])
->required(), ->required(),
Hidden::make('is_locked')
->default(true),
]) ])
->action(fn (array $data, AssignmentService $service) => $service->handle($this->getOwnerRecord()->node, $data, $this->getOwnerRecord())), ->action(fn (array $data, AssignmentService $service) => $service->handle($this->getOwnerRecord()->node, $data, $this->getOwnerRecord())),
AssociateAction::make() AssociateAction::make()

View File

@ -85,6 +85,7 @@ class AssignmentService
'port' => (int) $unit, 'port' => (int) $unit,
'ip_alias' => array_get($data, 'allocation_alias'), 'ip_alias' => array_get($data, 'allocation_alias'),
'server_id' => $server->id ?? null, 'server_id' => $server->id ?? null,
'is_locked' => array_get($data, 'is_locked', false),
]; ];
} }
} else { } else {
@ -98,6 +99,7 @@ class AssignmentService
'port' => (int) $port, 'port' => (int) $port,
'ip_alias' => array_get($data, 'allocation_alias'), 'ip_alias' => array_get($data, 'allocation_alias'),
'server_id' => $server->id ?? null, 'server_id' => $server->id ?? null,
'is_locked' => array_get($data, 'is_locked', false),
]; ];
} }