[2.x] [Filament] Update deprecated getFormSchema method to use form() override (#354)

This commit is contained in:
Rasel Islam Rafi 2024-11-29 02:13:10 +06:00 committed by GitHub
parent acdbfa70f5
commit d4ec4c66ed
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
30 changed files with 327 additions and 284 deletions

View File

@ -55,10 +55,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
->heading('')
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('logs')
->hiddenLabel()

View File

@ -46,10 +46,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
->heading('')
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->recordUrl(fn (Script $record) => Executions::getUrl(['script' => $record]))
->actions([
EditAction::make('edit')

View File

@ -25,8 +25,6 @@ protected function getTableQuery(): Builder
return CronJob::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -52,9 +50,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('enable')
->hiddenLabel()

View File

@ -26,8 +26,6 @@ protected function getTableQuery(): Builder
return BackupFile::query()->where('backup_id', $this->backup->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -54,9 +52,12 @@ protected function applyDefaultSortingToTableQuery(Builder $query): Builder
return $query->latest('created_at');
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('restore')
->hiddenLabel()

View File

@ -24,8 +24,6 @@ protected function getTableQuery(): Builder
return Backup::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -52,9 +50,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('files')
->hiddenLabel()

View File

@ -27,8 +27,6 @@ protected function getTableQuery(): Builder
return DatabaseUser::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -46,9 +44,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
$this->passwordAction(),
$this->linkAction(),

View File

@ -22,8 +22,6 @@ protected function getTableQuery(): Builder
return Database::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -41,9 +39,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('delete')
->hiddenLabel()

View File

@ -23,8 +23,6 @@ protected function getTableQuery(): Builder
return FirewallRule::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -44,9 +42,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('delete')
->icon('heroicon-o-trash')

View File

@ -23,8 +23,6 @@ class LogsList extends Widget
public ?Site $site = null;
public ?string $label = '';
public bool $remote = false;
protected $listeners = ['$refresh'];
@ -63,9 +61,12 @@ protected function applyDefaultSortingToTableQuery(Builder $query): Builder
/**
* @throws Exception
*/
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->filters([
Filter::make('created_at')
->form([
@ -84,7 +85,6 @@ public function getTable(): Table
);
}),
])
->heading($this->label)
->actions([
Action::make('view')
->hiddenLabel()

View File

@ -35,8 +35,6 @@ protected function getTableQuery(): Builder
return Service::query()->where('type', 'php')->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -62,9 +60,12 @@ protected function getTableColumns(): array
/**
* @throws Exception
*/
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
ActionGroup::make([
$this->installExtensionAction(),

View File

@ -28,8 +28,6 @@ protected function getTableQuery(): Builder
);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -44,9 +42,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
DeleteAction::make('delete')
->hiddenLabel()

View File

@ -28,8 +28,6 @@ protected function getTableQuery(): Builder
return Service::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = 'Installed Services';
protected function getTableColumns(): array
{
return [
@ -56,9 +54,12 @@ protected function getTableColumns(): array
/**
* @throws Exception
*/
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading('Installed Services')
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
ActionGroup::make([
$this->serviceAction('start', 'heroicon-o-play'),

View File

@ -34,8 +34,6 @@ protected function getTableQuery(): Builder
return Queue::query()->where('site_id', $this->site->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -57,9 +55,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
ActionGroup::make([
$this->editAction(),

View File

@ -24,8 +24,6 @@ protected function getTableQuery(): Builder
return Ssl::query()->where('site_id', $this->site->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -47,9 +45,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Action::make('logs')
->hiddenLabel()

View File

@ -22,8 +22,6 @@ protected function getTableQuery(): Builder
return Site::query()->where('server_id', $this->server->id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -54,9 +52,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->recordUrl(fn (Site $record) => View::getUrl(parameters: ['server' => $this->server, 'site' => $record]))
->actions([
Action::make('settings')

View File

@ -19,8 +19,6 @@ protected function getTableQuery(): Builder
return Server::query()->where('project_id', auth()->user()->current_project_id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -53,9 +51,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->recordUrl(fn (Server $record) => View::getUrl(parameters: ['server' => $record]))
->actions([
Action::make('settings')

View File

@ -41,10 +41,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
->heading('')
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
DeleteAction::make('delete')
->modalHeading('Delete Token')

View File

@ -47,10 +47,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
->heading('')
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
EditAction::make('edit')
->modalHeading('Edit Notification Channel')

View File

@ -9,6 +9,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Widgets\Widget;
@ -33,11 +34,12 @@ public function mount(): void
$this->timezone = auth()->user()->timezone;
}
public function getFormSchema(): array
public function form(Form $form): Form
{
$rules = UpdateUserProfileInformation::rules(auth()->user());
return [
return $form
->schema([
Section::make()
->heading('Profile Information')
->description('Update your account\'s profile information and email address.')
@ -62,7 +64,7 @@ public function getFormSchema(): array
->label('Save')
->action(fn () => $this->submit()),
]),
];
]);
}
public function submit(): void

View File

@ -8,6 +8,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Widgets\Widget;
@ -25,11 +26,12 @@ class UpdatePassword extends Widget implements HasForms
public string $password_confirmation = '';
public function getFormSchema(): array
public function form(Form $form): Form
{
$rules = UpdateUserPassword::rules();
return [
return $form
->schema([
Section::make()
->heading('Update Password')
->description('Ensure your account is using a long, random password to stay secure.')
@ -52,7 +54,7 @@ public function getFormSchema(): array
->label('Save')
->action(fn () => $this->submit()),
]),
];
]);
}
public function submit(): void

View File

@ -9,6 +9,7 @@
use Filament\Forms\Components\Select;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Widgets\Widget;
@ -27,9 +28,10 @@ public function mount(Project $project): void
$this->project = $project;
}
public function getFormSchema(): array
public function form(Form $form): Form
{
return [
return $form
->schema([
Section::make()
->heading('Add User')
->schema([
@ -44,7 +46,7 @@ public function getFormSchema(): array
->label('Add')
->action(fn () => $this->submit()),
]),
];
]);
}
public function submit(): void

View File

@ -36,9 +36,13 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table->actions([
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
Tables\Actions\DeleteAction::make()
->label('Remove')
->modalHeading('Remove user from project')
@ -48,6 +52,7 @@ public function getTable(): Table
->using(function ($record) {
$this->project->users()->detach($record);
}),
])->paginated(false);
])
->paginated(false);
}
}

View File

@ -19,8 +19,6 @@ protected function getTableQuery(): Builder
return Project::query();
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -35,9 +33,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->recordUrl(fn (Project $record) => Settings::getUrl(['project' => $record]))
->actions([
Action::make('settings')

View File

@ -8,6 +8,7 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Form;
use Filament\Notifications\Notification;
use Filament\Widgets\Widget;
@ -27,9 +28,10 @@ public function mount(Project $project): void
$this->name = $project->name;
}
public function getFormSchema(): array
public function form(Form $form): Form
{
return [
return $form
->schema([
Section::make()
->heading('Project Information')
->schema([
@ -44,7 +46,7 @@ public function getFormSchema(): array
->label('Save')
->action(fn () => $this->submit()),
]),
];
]);
}
public function submit(): void

View File

@ -18,8 +18,6 @@ protected function getTableQuery(): Builder
return SshKey::query()->where('user_id', auth()->id());
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -35,9 +33,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
DeleteAction::make('delete')
->requiresConfirmation()

View File

@ -25,8 +25,6 @@ protected function getTableQuery(): Builder
return ServerProvider::getByProjectId(auth()->user()->current_project_id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -53,9 +51,13 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table->actions([
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
EditAction::make('edit')
->label('Edit')
->modalHeading('Edit Server Provider')

View File

@ -25,8 +25,6 @@ protected function getTableQuery(): Builder
return SourceControl::getByProjectId(auth()->user()->current_project_id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -53,9 +51,13 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table->actions([
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
EditAction::make('edit')
->label('Edit')
->modalHeading('Edit Source Control')

View File

@ -24,8 +24,6 @@ protected function getTableQuery(): Builder
return StorageProvider::getByProjectId(auth()->user()->current_project_id);
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -53,9 +51,13 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table->actions([
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
EditAction::make('edit')
->label('Edit')
->modalHeading('Edit Storage Provider')

View File

@ -42,7 +42,7 @@ protected function getTableColumns(): array
public function table(Table $table): Table
{
return $table
->heading('')
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([

View File

@ -29,8 +29,6 @@ protected function getTableQuery(): Builder
return User::query();
}
protected static ?string $heading = '';
protected function getTableColumns(): array
{
return [
@ -50,9 +48,12 @@ protected function getTableColumns(): array
];
}
public function getTable(): Table
public function table(Table $table): Table
{
return $this->table
return $table
->heading(null)
->query($this->getTableQuery())
->columns($this->getTableColumns())
->actions([
EditAction::make('edit')
->authorize(fn ($record) => auth()->user()->can('update', $record))