From 168d37b996fcb471d5b901470ee060dab667ace8 Mon Sep 17 00:00:00 2001 From: MartinOscar <40749467+RMartinOscar@users.noreply.github.com> Date: Sat, 4 Jan 2025 19:58:51 +0100 Subject: [PATCH] Add missing externalId on Server creation (#859) * Add missing externalId on server creation * Pint * Fix mobile layout * fix layout --------- Co-authored-by: notCharles --- .../ServerResource/Pages/CreateServer.php | 83 ++++++++++--------- .../ServerResource/Pages/EditServer.php | 1 + 2 files changed, 44 insertions(+), 40 deletions(-) diff --git a/app/Filament/Admin/Resources/ServerResource/Pages/CreateServer.php b/app/Filament/Admin/Resources/ServerResource/Pages/CreateServer.php index f56957edc6..745e45aa76 100644 --- a/app/Filament/Admin/Resources/ServerResource/Pages/CreateServer.php +++ b/app/Filament/Admin/Resources/ServerResource/Pages/CreateServer.php @@ -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') @@ -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']) @@ -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']) @@ -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) @@ -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'), ]), diff --git a/app/Filament/Admin/Resources/ServerResource/Pages/EditServer.php b/app/Filament/Admin/Resources/ServerResource/Pages/EditServer.php index 064fb8dfc7..1adc1a2d7b 100644 --- a/app/Filament/Admin/Resources/ServerResource/Pages/EditServer.php +++ b/app/Filament/Admin/Resources/ServerResource/Pages/EditServer.php @@ -161,6 +161,7 @@ public function form(Form $form): Form 'md' => 2, 'lg' => 3, ]) + ->unique() ->maxLength(255), Select::make('node_id') ->label('Node')