Add restore to simplify form

This commit is contained in:
Lance Pioch 2024-06-18 10:59:56 -04:00
parent d4484f5254
commit 48fd3cc84e

View File

@ -461,6 +461,13 @@ class EditServer extends EditRecord
Forms\Components\Textarea::make('startup') Forms\Components\Textarea::make('startup')
->label('Startup Command') ->label('Startup Command')
->required() ->required()
->hintAction(Forms\Components\Actions\Action::make('startup-restore')
->label('Restore Default')
->icon('tabler-restore')
->action(fn (Forms\Get $get, Forms\Set $set) =>
$set('startup', Egg::find($get('egg_id'))?->startup ?? '')
)
)
->columnSpan([ ->columnSpan([
'default' => 2, 'default' => 2,
'sm' => 4, 'sm' => 4,
@ -474,22 +481,6 @@ class EditServer extends EditRecord
); );
}), }),
Forms\Components\Textarea::make('defaultStartup')
->hintAction(CopyAction::make())
->label('Default Startup Command')
->disabled()
->formatStateUsing(function ($state, Forms\Get $get, Forms\Set $set) {
$egg = Egg::query()->find($get('egg_id'));
return $egg->startup;
})
->columnSpan([
'default' => 2,
'sm' => 4,
'md' => 4,
'lg' => 6,
]),
Forms\Components\Repeater::make('server_variables') Forms\Components\Repeater::make('server_variables')
->relationship('serverVariables') ->relationship('serverVariables')
->grid() ->grid()