Add missing externalId on Server creation (#859)

* Add missing externalId on server creation

* Pint

* Fix mobile layout

* fix layout

---------

Co-authored-by: notCharles <charles@pelican.dev>
This commit is contained in:
MartinOscar 2025-01-04 19:58:51 +01:00 committed by GitHub
parent df615f6915
commit 168d37b996
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 44 additions and 40 deletions

View File

@ -70,9 +70,8 @@ class CreateServer extends CreateRecord
->completedIcon('tabler-check') ->completedIcon('tabler-check')
->columns([ ->columns([
'default' => 1, 'default' => 1,
'sm' => 1, 'sm' => 4,
'md' => 4, 'md' => 4,
'lg' => 6,
]) ])
->schema([ ->schema([
TextInput::make('name') TextInput::make('name')
@ -89,24 +88,51 @@ class CreateServer extends CreateRecord
$set('name', $prefix . $word); $set('name', $prefix . $word);
})) }))
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 1,
'sm' => 3, 'sm' => 2,
'md' => 2, 'md' => 2,
'lg' => 3,
]) ])
->required() ->required()
->maxLength(255), ->maxLength(255),
TextInput::make('external_id')
->label('External ID')
->columnSpan([
'default' => 1,
'sm' => 2,
'md' => 2,
])
->unique()
->maxLength(255),
Select::make('node_id')
->disabledOn('edit')
->prefixIcon('tabler-server-2')
->default(fn () => ($this->node = Node::query()->latest()->first())?->id)
->columnSpan([
'default' => 1,
'sm' => 2,
'md' => 2,
])
->live()
->relationship('node', 'name')
->searchable()
->preload()
->afterStateUpdated(function (Set $set, $state) {
$set('allocation_id', null);
$this->node = Node::find($state);
})
->required(),
Select::make('owner_id') Select::make('owner_id')
->preload() ->preload()
->prefixIcon('tabler-user') ->prefixIcon('tabler-user')
->default(auth()->user()->id) ->default(auth()->user()->id)
->label('Owner') ->label('Owner')
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 1,
'sm' => 3, 'sm' => 2,
'md' => 3, 'md' => 2,
'lg' => 3,
]) ])
->relationship('user', 'username') ->relationship('user', 'username')
->searchable(['username', 'email']) ->searchable(['username', 'email'])
@ -136,36 +162,15 @@ class CreateServer extends CreateRecord
}) })
->required(), ->required(),
Select::make('node_id')
->disabledOn('edit')
->prefixIcon('tabler-server-2')
->default(fn () => ($this->node = Node::query()->latest()->first())?->id)
->columnSpan([
'default' => 2,
'sm' => 3,
'md' => 6,
'lg' => 6,
])
->live()
->relationship('node', 'name')
->searchable()
->preload()
->afterStateUpdated(function (Set $set, $state) {
$set('allocation_id', null);
$this->node = Node::find($state);
})
->required(),
Select::make('allocation_id') Select::make('allocation_id')
->preload() ->preload()
->live() ->live()
->prefixIcon('tabler-network') ->prefixIcon('tabler-network')
->label('Primary Allocation') ->label('Primary Allocation')
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 1,
'sm' => 3, 'sm' => 2,
'md' => 2, 'md' => 2,
'lg' => 3,
]) ])
->disabled(fn (Get $get) => $get('node_id') === null) ->disabled(fn (Get $get) => $get('node_id') === null)
->searchable(['ip', 'port', 'ip_alias']) ->searchable(['ip', 'port', 'ip_alias'])
@ -283,10 +288,9 @@ class CreateServer extends CreateRecord
Repeater::make('allocation_additional') Repeater::make('allocation_additional')
->label('Additional Allocations') ->label('Additional Allocations')
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 1,
'sm' => 3, 'sm' => 2,
'md' => 3, 'md' => 2,
'lg' => 3,
]) ])
->addActionLabel('Add Allocation') ->addActionLabel('Add Allocation')
->disabled(fn (Get $get) => $get('allocation_id') === null) ->disabled(fn (Get $get) => $get('allocation_id') === null)
@ -322,10 +326,9 @@ class CreateServer extends CreateRecord
->placeholder('Description') ->placeholder('Description')
->rows(3) ->rows(3)
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 1,
'sm' => 6, 'sm' => 4,
'md' => 6, 'md' => 4,
'lg' => 6,
]) ])
->label('Description'), ->label('Description'),
]), ]),

View File

@ -161,6 +161,7 @@ class EditServer extends EditRecord
'md' => 2, 'md' => 2,
'lg' => 3, 'lg' => 3,
]) ])
->unique()
->maxLength(255), ->maxLength(255),
Select::make('node_id') Select::make('node_id')
->label('Node') ->label('Node')