Skip to content

Commit

Permalink
Add missing externalId on Server creation (#859)
Browse files Browse the repository at this point in the history
* Add missing externalId on server creation

* Pint

* Fix mobile layout

* fix layout

---------

Co-authored-by: notCharles <[email protected]>
  • Loading branch information
RMartinOscar and notAreYouScared authored Jan 4, 2025
1 parent df615f6 commit 168d37b
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 40 deletions.
83 changes: 43 additions & 40 deletions app/Filament/Admin/Resources/ServerResource/Pages/CreateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,8 @@ public function form(Form $form): Form
->completedIcon('tabler-check')
->columns([
'default' => 1,
'sm' => 1,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->schema([
TextInput::make('name')
Expand All @@ -89,24 +88,51 @@ public function form(Form $form): Form
$set('name', $prefix . $word);
}))
->columnSpan([
'default' => 2,
'sm' => 3,
'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->required()
->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')
->preload()
->prefixIcon('tabler-user')
->default(auth()->user()->id)
->label('Owner')
->columnSpan([
'default' => 2,
'sm' => 3,
'md' => 3,
'lg' => 3,
'default' => 1,
'sm' => 2,
'md' => 2,
])
->relationship('user', 'username')
->searchable(['username', 'email'])
Expand Down Expand Up @@ -136,36 +162,15 @@ public function form(Form $form): Form
})
->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')
->preload()
->live()
->prefixIcon('tabler-network')
->label('Primary Allocation')
->columnSpan([
'default' => 2,
'sm' => 3,
'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 3,
])
->disabled(fn (Get $get) => $get('node_id') === null)
->searchable(['ip', 'port', 'ip_alias'])
Expand Down Expand Up @@ -283,10 +288,9 @@ public function form(Form $form): Form
Repeater::make('allocation_additional')
->label('Additional Allocations')
->columnSpan([
'default' => 2,
'sm' => 3,
'md' => 3,
'lg' => 3,
'default' => 1,
'sm' => 2,
'md' => 2,
])
->addActionLabel('Add Allocation')
->disabled(fn (Get $get) => $get('allocation_id') === null)
Expand Down Expand Up @@ -322,10 +326,9 @@ public function form(Form $form): Form
->placeholder('Description')
->rows(3)
->columnSpan([
'default' => 2,
'sm' => 6,
'md' => 6,
'lg' => 6,
'default' => 1,
'sm' => 4,
'md' => 4,
])
->label('Description'),
]),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,7 @@ public function form(Form $form): Form
'md' => 2,
'lg' => 3,
])
->unique()
->maxLength(255),
Select::make('node_id')
->label('Node')
Expand Down

0 comments on commit 168d37b

Please sign in to comment.