mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-19 22:14:45 +02:00
Add validation
& missing reserved vars
to EggVariables
(#954)
* Add validation & Add missing reserved vars
* env_var not env_name 🤦
* Custom validationMessages
This commit is contained in:
parent
e352754e6f
commit
dde5305b3f
@ -4,6 +4,7 @@ namespace App\Filament\Admin\Resources\EggResource\Pages;
|
||||
|
||||
use AbdelhamidErrahmouni\FilamentMonacoEditor\MonacoEditor;
|
||||
use App\Filament\Admin\Resources\EggResource;
|
||||
use App\Models\EggVariable;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
use Filament\Forms\Components\Hidden;
|
||||
@ -189,8 +190,11 @@ class CreateEgg extends CreateRecord
|
||||
->hintIcon('tabler-code')
|
||||
->hintIconTooltip(fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->rules(EggVariable::$validationRules['env_variable'])
|
||||
->validationMessages([
|
||||
'unique' => 'A variable with this name already exists.',
|
||||
'required' => ' The environment variable field is required.',
|
||||
'*' => 'This environment variable is reserved and cannot be used.',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('default_value')->maxLength(255),
|
||||
|
@ -8,6 +8,7 @@ use App\Filament\Admin\Resources\EggResource\RelationManagers\ServersRelationMan
|
||||
use App\Filament\Components\Actions\ExportEggAction;
|
||||
use App\Filament\Components\Actions\ImportEggAction;
|
||||
use App\Models\Egg;
|
||||
use App\Models\EggVariable;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Forms\Components\Checkbox;
|
||||
use Filament\Forms\Components\Fieldset;
|
||||
@ -180,8 +181,11 @@ class EditEgg extends EditRecord
|
||||
->hintIcon('tabler-code')
|
||||
->hintIconTooltip(fn ($state) => "{{{$state}}}")
|
||||
->unique(modifyRuleUsing: fn (Unique $rule, Get $get) => $rule->where('egg_id', $get('../../id')), ignoreRecord: true)
|
||||
->rules(EggVariable::$validationRules['env_variable'])
|
||||
->validationMessages([
|
||||
'unique' => 'A variable with this name already exists.',
|
||||
'required' => ' The environment variable field is required.',
|
||||
'*' => 'This environment variable is reserved and cannot be used.',
|
||||
])
|
||||
->required(),
|
||||
TextInput::make('default_value')->maxLength(255),
|
||||
|
@ -37,7 +37,7 @@ class EggVariable extends Model
|
||||
/**
|
||||
* Reserved environment variable names.
|
||||
*/
|
||||
public const RESERVED_ENV_NAMES = 'SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,SERVER_UUID,UUID';
|
||||
public const RESERVED_ENV_NAMES = 'P_SERVER_UUID,P_SERVER_ALLOCATION_LIMIT,SERVER_MEMORY,SERVER_IP,SERVER_PORT,ENV,HOME,USER,STARTUP,MODIFIED_STARTUP,SERVER_UUID,UUID,INTERNAL_IP';
|
||||
|
||||
/**
|
||||
* The table associated with the model.
|
||||
|
Loading…
x
Reference in New Issue
Block a user