Skip to content

Commit

Permalink
Add toggle for starting server after install
Browse files Browse the repository at this point in the history
  • Loading branch information
notAreYouScared committed Aug 25, 2024
1 parent 58307c1 commit e152efc
Showing 1 changed file with 35 additions and 13 deletions.
48 changes: 35 additions & 13 deletions app/Filament/Resources/ServerResource/Pages/CreateServer.php
Original file line number Diff line number Diff line change
Expand Up @@ -321,9 +321,9 @@ public function form(Form $form): Form
->completedIcon('tabler-check')
->columns([
'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 4,
'sm' => 4,
'md' => 4,
'lg' => 6,
])
->schema([
Forms\Components\Select::make('egg_id')
Expand All @@ -333,7 +333,7 @@ public function form(Form $form): Form
'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 3,
'lg' => 4,
])
->searchable()
->preload()
Expand Down Expand Up @@ -390,29 +390,51 @@ public function form(Form $form): Form
->inline()
->required(),

Forms\Components\ToggleButtons::make('start_on_completion')
->label('Start Server After Install?')
->default(true)
->required()
->columnSpan([
'default' => 1,
'sm' => 1,
'md' => 1,
'lg' => 1,
])
->options([
true => 'Yes',
false => 'No',
])
->colors([
true => 'primary',
false => 'danger',
])
->icons([
true => 'tabler-code',
false => 'tabler-code-off',
])
->inline(),

Forms\Components\Textarea::make('startup')
->hintIcon('tabler-code')
->label('Startup Command')
->hidden(fn (Forms\Get $get) => $get('egg_id') === null)
->required()
->live()
->columnSpan([
'default' => 1,
'sm' => 2,
'md' => 2,
'lg' => 4,
])
->rows(function ($state) {
return str($state)->explode("\n")->reduce(
fn (int $carry, $line) => $carry + floor(strlen($line) / 125),
1
);
}),
})
->columnSpan([
'default' => 1,
'sm' => 4,
'md' => 4,
'lg' => 6,
]),

Forms\Components\Hidden::make('environment')->default([]),

Forms\Components\Hidden::make('start_on_completion')->default(true),

Forms\Components\Section::make('Variables')
->icon('tabler-eggs')
->iconColor('primary')
Expand Down

0 comments on commit e152efc

Please sign in to comment.