This commit is contained in:
Saeed Vaziry
2024-10-13 12:33:12 +02:00
parent 386d8e73a7
commit 224e0ac2b0
49 changed files with 3668 additions and 766 deletions

View File

@ -9,6 +9,8 @@
use App\Web\Pages\Settings\SourceControls\Actions\Create;
use Filament\Actions\Action;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\Component;
use Filament\Forms\Components\Grid;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\TagsInput;
use Filament\Forms\Components\TextInput;
@ -53,6 +55,7 @@ protected function getHeaderActions(): array
->slideOver()
->form([
Select::make('type')
->label('Site Type')
->options(
collect(config('core.site_types'))->mapWithKeys(fn ($type) => [$type => $type])
)
@ -119,6 +122,17 @@ protected function getHeaderActions(): array
->label('Run `composer install --no-dev`')
->default(false)
->visible(fn (Get $get) => isset(CreateSite::rules($this->server, $get())['composer'])),
// PHPMyAdmin
Select::make('version')
->label('PHPMyAdmin Version')
->validationAttribute('PHPMyAdmin Version')
->options([
'5.2.1' => '5.2.1',
])
->visible(fn (Get $get) => $get('type') === SiteType::PHPMYADMIN)
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['version']),
// WordPress
$this->wordpressFields(),
])
->action(function (array $data) {
$this->authorize('create', [Site::class, $this->server]);
@ -128,7 +142,7 @@ protected function getHeaderActions(): array
try {
$site = app(CreateSite::class)->create($this->server, $data);
$this->redirect(\App\Web\Pages\Servers\Sites\View::getUrl([
$this->redirect(View::getUrl([
'server' => $this->server,
'site' => $site,
]));
@ -142,4 +156,35 @@ protected function getHeaderActions(): array
->modalSubmitActionLabel('Create Site'),
];
}
private function wordpressFields(): Component
{
return Grid::make()
->columns(3)
->visible(fn (Get $get) => $get('type') === SiteType::WORDPRESS)
->schema([
TextInput::make('title')
->label('Site Title')
->columnSpan(3)
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['title']),
TextInput::make('email')
->label('WP Admin Email')
->default(auth()->user()?->email)
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['email']),
TextInput::make('username')
->label('WP Admin Username')
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['username']),
TextInput::make('password')
->label('WP Admin Password')
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['password']),
TextInput::make('database')
->helperText('It will create a database with this name')
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['database']),
TextInput::make('database_user')
->helperText('It will create a db user with this username')
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['database']),
TextInput::make('database_password')
->rules(fn (Get $get) => CreateSite::rules($this->server, $get())['database']),
]);
}
}