- 2.x - sites settings

- tags
- source-control soft deletes
This commit is contained in:
Saeed Vaziry
2024-10-06 00:04:57 +02:00
parent d1f2add699
commit 3c50e2c947
44 changed files with 972 additions and 119 deletions

View File

@ -2,25 +2,53 @@
namespace App\Web\Pages\Settings\SourceControls\Actions;
use App\Actions\SourceControl\ConnectSourceControl;
use App\Actions\SourceControl\EditSourceControl;
use App\Models\SourceControl;
use App\Enums\SourceControl;
use Exception;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\TextInput;
use Filament\Forms\Get;
use Filament\Notifications\Notification;
class Edit
{
public static function form(): array
{
return Create::form();
return [
TextInput::make('name')
->rules(fn (Get $get) => ConnectSourceControl::rules($get())['name']),
TextInput::make('token')
->label('API Key')
->validationAttribute('API Key')
->visible(fn ($get) => in_array($get('provider'), [
SourceControl::GITHUB,
SourceControl::GITLAB,
]))
->rules(fn (Get $get) => ConnectSourceControl::rules($get())['token']),
TextInput::make('url')
->label('URL (optional)')
->visible(fn ($get) => $get('provider') == SourceControl::GITLAB)
->rules(fn (Get $get) => ConnectSourceControl::rules($get())['url'])
->helperText('If you run a self-managed gitlab enter the url here, leave empty to use gitlab.com'),
TextInput::make('username')
->visible(fn ($get) => $get('provider') == SourceControl::BITBUCKET)
->rules(fn (Get $get) => ConnectSourceControl::rules($get())['username']),
TextInput::make('password')
->visible(fn ($get) => $get('provider') == SourceControl::BITBUCKET)
->rules(fn (Get $get) => ConnectSourceControl::rules($get())['password']),
Checkbox::make('global')
->label('Is Global (Accessible in all projects)'),
];
}
/**
* @throws Exception
*/
public static function action(SourceControl $provider, array $data): void
public static function action(\App\Models\SourceControl $sourceControl, array $data): void
{
try {
app(EditSourceControl::class)->edit($provider, auth()->user(), $data);
app(EditSourceControl::class)->edit($sourceControl, auth()->user(), $data);
} catch (Exception $e) {
Notification::make()
->title($e->getMessage())