mirror of
				https://github.com/pelican-dev/panel.git
				synced 2025-10-31 04:36:51 +01:00 
			
		
		
		
	 f8ad720f52
			
		
	
	
		f8ad720f52
		
			
		
	
	
	
	
		
			
			* Init * Health Page * Admin API Keys * Update API Keys * Database Hosts * Mounts * remove `s` * Users * Webhooks * Server never again... * Fix Server * Settings * Update Mounts * Update Databasehost * Update Server * Oops, Update Server * Nodes * Update User * Dashboard * Update Server * Profile * Egg * Role & Update Egg * Add base Laravel lang files * update apikey * remove html back to settings, remove comment * add `:resource` to create_action * Update Egg * Update Egg v2 * Update 1 * trans cf info label * Update charts * more trans * Update Webhook * update Health * Update Server * Update Role * Fixes * Bulk Update * AnotherOne * Fix relation button label * rename `admin1` to `admin` Leftover from testing... oops * More Translations * Updates * `pint` + Relation Manager Titles
		
			
				
	
	
		
			130 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			130 lines
		
	
	
		
			4.7 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| namespace App\Filament\Admin\Resources\MountResource\Pages;
 | |
| 
 | |
| use App\Filament\Admin\Resources\MountResource;
 | |
| use Filament\Forms\Components\Group;
 | |
| use Filament\Forms\Components\Hidden;
 | |
| use Filament\Forms\Components\Section;
 | |
| use Filament\Forms\Components\Select;
 | |
| use Filament\Forms\Components\Textarea;
 | |
| use Filament\Forms\Components\TextInput;
 | |
| use Filament\Forms\Components\ToggleButtons;
 | |
| use Filament\Forms\Form;
 | |
| use Filament\Resources\Pages\CreateRecord;
 | |
| use Illuminate\Database\Eloquent\Model;
 | |
| use Illuminate\Support\Str;
 | |
| 
 | |
| class CreateMount extends CreateRecord
 | |
| {
 | |
|     protected static string $resource = MountResource::class;
 | |
| 
 | |
|     protected static bool $canCreateAnother = false;
 | |
| 
 | |
|     protected function getHeaderActions(): array
 | |
|     {
 | |
|         return [
 | |
|             $this->getCreateFormAction()->formId('form'),
 | |
|         ];
 | |
|     }
 | |
| 
 | |
|     protected function getFormActions(): array
 | |
|     {
 | |
|         return [];
 | |
|     }
 | |
| 
 | |
|     public function form(Form $form): Form
 | |
|     {
 | |
|         return $form
 | |
|             ->schema([
 | |
|                 Section::make()->schema([
 | |
|                     TextInput::make('name')
 | |
|                         ->label(trans('admin/mount.name'))
 | |
|                         ->required()
 | |
|                         ->helperText(trans('admin/mount.name_help'))
 | |
|                         ->maxLength(64),
 | |
|                     ToggleButtons::make('read_only')
 | |
|                         ->label(trans('admin/mount.read_only'))
 | |
|                         ->helperText(trans('admin/mount.read_only_help'))
 | |
|                         ->options([
 | |
|                             false => trans('admin/mount.toggles.writable'),
 | |
|                             true => trans('admin/mount.toggles.read_only'),
 | |
|                         ])
 | |
|                         ->icons([
 | |
|                             false => 'tabler-writing',
 | |
|                             true => 'tabler-writing-off',
 | |
|                         ])
 | |
|                         ->colors([
 | |
|                             false => 'warning',
 | |
|                             true => 'success',
 | |
|                         ])
 | |
|                         ->inline()
 | |
|                         ->default(false)
 | |
|                         ->required(),
 | |
|                     TextInput::make('source')
 | |
|                         ->label(trans('admin/mount.source'))
 | |
|                         ->required()
 | |
|                         ->helperText(trans('admin/mount.source_help'))
 | |
|                         ->maxLength(255),
 | |
|                     TextInput::make('target')
 | |
|                         ->label(trans('admin/mount.target'))
 | |
|                         ->required()
 | |
|                         ->helperText(trans('admin/mount.target_help'))
 | |
|                         ->maxLength(255),
 | |
|                     ToggleButtons::make('user_mountable')
 | |
|                         ->hidden()
 | |
|                         ->label('User mountable?')
 | |
|                         ->options([
 | |
|                             false => 'No',
 | |
|                             true => 'Yes',
 | |
|                         ])
 | |
|                         ->icons([
 | |
|                             false => 'tabler-user-cancel',
 | |
|                             true => 'tabler-user-bolt',
 | |
|                         ])
 | |
|                         ->colors([
 | |
|                             false => 'success',
 | |
|                             true => 'warning',
 | |
|                         ])
 | |
|                         ->default(false)
 | |
|                         ->inline()
 | |
|                         ->required(),
 | |
|                     Textarea::make('description')
 | |
|                         ->label(trans('admin/mount.description'))
 | |
|                         ->helperText(trans('admin/mount.description_help'))
 | |
|                         ->columnSpanFull(),
 | |
|                     Hidden::make('user_mountable')->default(1),
 | |
|                 ])->columnSpan(1)->columns([
 | |
|                     'default' => 1,
 | |
|                     'lg' => 2,
 | |
|                 ]),
 | |
|                 Group::make()->schema([
 | |
|                     Section::make()->schema([
 | |
|                         Select::make('eggs')->multiple()
 | |
|                             ->label(trans('admin/mount.eggs'))
 | |
|                             ->relationship('eggs', 'name')
 | |
|                             ->preload(),
 | |
|                         Select::make('nodes')->multiple()
 | |
|                             ->label(trans('admin/mount.nodes'))
 | |
|                             ->relationship('nodes', 'name')
 | |
|                             ->searchable(['name', 'fqdn'])
 | |
|                             ->preload(),
 | |
|                     ]),
 | |
|                 ])->columns([
 | |
|                     'default' => 1,
 | |
|                     'lg' => 2,
 | |
|                 ]),
 | |
|             ])->columns([
 | |
|                 'default' => 1,
 | |
|                 'lg' => 2,
 | |
|             ]);
 | |
|     }
 | |
| 
 | |
|     protected function handleRecordCreation(array $data): Model
 | |
|     {
 | |
|         $data['uuid'] ??= Str::uuid()->toString();
 | |
| 
 | |
|         return parent::handleRecordCreation($data);
 | |
|     }
 | |
| }
 |