From d4ec4c66ede01a5ef986906bb57ea5057571d9c8 Mon Sep 17 00:00:00 2001 From: Rasel Islam Rafi <31556372+rtraselbd@users.noreply.github.com> Date: Fri, 29 Nov 2024 02:13:10 +0600 Subject: [PATCH] [2.x] [Filament] Update deprecated `getFormSchema` method to use `form()` override (#354) --- .../Scripts/Widgets/ScriptExecutionsList.php | 8 +- app/Web/Pages/Scripts/Widgets/ScriptsList.php | 8 +- .../Servers/CronJobs/Widgets/CronJobsList.php | 9 +- .../Databases/Widgets/BackupFilesList.php | 9 +- .../Servers/Databases/Widgets/BackupsList.php | 9 +- .../Databases/Widgets/DatabaseUsersList.php | 9 +- .../Databases/Widgets/DatabasesList.php | 9 +- .../Servers/Firewall/Widgets/RulesList.php | 9 +- .../Pages/Servers/Logs/Widgets/LogsList.php | 10 +-- app/Web/Pages/Servers/PHP/Widgets/PHPList.php | 9 +- .../Servers/SSHKeys/Widgets/SshKeysList.php | 9 +- .../Servers/Services/Widgets/ServicesList.php | 9 +- .../Sites/Pages/Queues/Widgets/QueuesList.php | 9 +- .../Sites/Pages/SSL/Widgets/SslsList.php | 9 +- .../Pages/Servers/Sites/Widgets/SitesList.php | 9 +- app/Web/Pages/Servers/Widgets/ServersList.php | 9 +- .../Settings/APIKeys/Widgets/ApiKeysList.php | 8 +- .../Widgets/NotificationChannelsList.php | 8 +- .../Profile/Widgets/ProfileInformation.php | 56 +++++++------ .../Profile/Widgets/UpdatePassword.php | 52 ++++++------ .../Settings/Projects/Widgets/AddUser.php | 36 ++++---- .../Projects/Widgets/ProjectUsersList.php | 29 ++++--- .../Projects/Widgets/ProjectsList.php | 9 +- .../Projects/Widgets/UpdateProject.php | 36 ++++---- .../Settings/SSHKeys/Widgets/SshKeysList.php | 9 +- .../Widgets/ServerProvidersList.php | 66 +++++++-------- .../Widgets/SourceControlsList.php | 82 ++++++++++--------- .../Widgets/StorageProvidersList.php | 66 +++++++-------- .../Pages/Settings/Tags/Widgets/TagsList.php | 2 +- .../Settings/Users/Widgets/UsersList.php | 9 +- 30 files changed, 327 insertions(+), 284 deletions(-) diff --git a/app/Web/Pages/Scripts/Widgets/ScriptExecutionsList.php b/app/Web/Pages/Scripts/Widgets/ScriptExecutionsList.php index 46a5495..b5ee167 100644 --- a/app/Web/Pages/Scripts/Widgets/ScriptExecutionsList.php +++ b/app/Web/Pages/Scripts/Widgets/ScriptExecutionsList.php @@ -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() diff --git a/app/Web/Pages/Scripts/Widgets/ScriptsList.php b/app/Web/Pages/Scripts/Widgets/ScriptsList.php index aa33a7d..95daad5 100644 --- a/app/Web/Pages/Scripts/Widgets/ScriptsList.php +++ b/app/Web/Pages/Scripts/Widgets/ScriptsList.php @@ -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') diff --git a/app/Web/Pages/Servers/CronJobs/Widgets/CronJobsList.php b/app/Web/Pages/Servers/CronJobs/Widgets/CronJobsList.php index 1adf104..39c8b2f 100644 --- a/app/Web/Pages/Servers/CronJobs/Widgets/CronJobsList.php +++ b/app/Web/Pages/Servers/CronJobs/Widgets/CronJobsList.php @@ -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() diff --git a/app/Web/Pages/Servers/Databases/Widgets/BackupFilesList.php b/app/Web/Pages/Servers/Databases/Widgets/BackupFilesList.php index 40d860f..eab0a35 100644 --- a/app/Web/Pages/Servers/Databases/Widgets/BackupFilesList.php +++ b/app/Web/Pages/Servers/Databases/Widgets/BackupFilesList.php @@ -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() diff --git a/app/Web/Pages/Servers/Databases/Widgets/BackupsList.php b/app/Web/Pages/Servers/Databases/Widgets/BackupsList.php index 519d3b7..c8cd449 100644 --- a/app/Web/Pages/Servers/Databases/Widgets/BackupsList.php +++ b/app/Web/Pages/Servers/Databases/Widgets/BackupsList.php @@ -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() diff --git a/app/Web/Pages/Servers/Databases/Widgets/DatabaseUsersList.php b/app/Web/Pages/Servers/Databases/Widgets/DatabaseUsersList.php index 90741a1..5818881 100644 --- a/app/Web/Pages/Servers/Databases/Widgets/DatabaseUsersList.php +++ b/app/Web/Pages/Servers/Databases/Widgets/DatabaseUsersList.php @@ -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(), diff --git a/app/Web/Pages/Servers/Databases/Widgets/DatabasesList.php b/app/Web/Pages/Servers/Databases/Widgets/DatabasesList.php index 00f0087..82b73df 100644 --- a/app/Web/Pages/Servers/Databases/Widgets/DatabasesList.php +++ b/app/Web/Pages/Servers/Databases/Widgets/DatabasesList.php @@ -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() diff --git a/app/Web/Pages/Servers/Firewall/Widgets/RulesList.php b/app/Web/Pages/Servers/Firewall/Widgets/RulesList.php index f34f4b2..42a9a3e 100644 --- a/app/Web/Pages/Servers/Firewall/Widgets/RulesList.php +++ b/app/Web/Pages/Servers/Firewall/Widgets/RulesList.php @@ -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') diff --git a/app/Web/Pages/Servers/Logs/Widgets/LogsList.php b/app/Web/Pages/Servers/Logs/Widgets/LogsList.php index 4cf7a8d..2bf8a32 100644 --- a/app/Web/Pages/Servers/Logs/Widgets/LogsList.php +++ b/app/Web/Pages/Servers/Logs/Widgets/LogsList.php @@ -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() diff --git a/app/Web/Pages/Servers/PHP/Widgets/PHPList.php b/app/Web/Pages/Servers/PHP/Widgets/PHPList.php index 9bd7180..1ba5f82 100644 --- a/app/Web/Pages/Servers/PHP/Widgets/PHPList.php +++ b/app/Web/Pages/Servers/PHP/Widgets/PHPList.php @@ -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(), diff --git a/app/Web/Pages/Servers/SSHKeys/Widgets/SshKeysList.php b/app/Web/Pages/Servers/SSHKeys/Widgets/SshKeysList.php index 57fcd27..93cb422 100644 --- a/app/Web/Pages/Servers/SSHKeys/Widgets/SshKeysList.php +++ b/app/Web/Pages/Servers/SSHKeys/Widgets/SshKeysList.php @@ -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() diff --git a/app/Web/Pages/Servers/Services/Widgets/ServicesList.php b/app/Web/Pages/Servers/Services/Widgets/ServicesList.php index 09e5a1d..095bfdf 100644 --- a/app/Web/Pages/Servers/Services/Widgets/ServicesList.php +++ b/app/Web/Pages/Servers/Services/Widgets/ServicesList.php @@ -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'), diff --git a/app/Web/Pages/Servers/Sites/Pages/Queues/Widgets/QueuesList.php b/app/Web/Pages/Servers/Sites/Pages/Queues/Widgets/QueuesList.php index 23eb5cf..91ed497 100644 --- a/app/Web/Pages/Servers/Sites/Pages/Queues/Widgets/QueuesList.php +++ b/app/Web/Pages/Servers/Sites/Pages/Queues/Widgets/QueuesList.php @@ -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(), diff --git a/app/Web/Pages/Servers/Sites/Pages/SSL/Widgets/SslsList.php b/app/Web/Pages/Servers/Sites/Pages/SSL/Widgets/SslsList.php index 0da2e86..94f0480 100644 --- a/app/Web/Pages/Servers/Sites/Pages/SSL/Widgets/SslsList.php +++ b/app/Web/Pages/Servers/Sites/Pages/SSL/Widgets/SslsList.php @@ -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() diff --git a/app/Web/Pages/Servers/Sites/Widgets/SitesList.php b/app/Web/Pages/Servers/Sites/Widgets/SitesList.php index b94df30..7b69461 100644 --- a/app/Web/Pages/Servers/Sites/Widgets/SitesList.php +++ b/app/Web/Pages/Servers/Sites/Widgets/SitesList.php @@ -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') diff --git a/app/Web/Pages/Servers/Widgets/ServersList.php b/app/Web/Pages/Servers/Widgets/ServersList.php index 517b53a..36fb85a 100644 --- a/app/Web/Pages/Servers/Widgets/ServersList.php +++ b/app/Web/Pages/Servers/Widgets/ServersList.php @@ -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') diff --git a/app/Web/Pages/Settings/APIKeys/Widgets/ApiKeysList.php b/app/Web/Pages/Settings/APIKeys/Widgets/ApiKeysList.php index cfc56ee..a610368 100644 --- a/app/Web/Pages/Settings/APIKeys/Widgets/ApiKeysList.php +++ b/app/Web/Pages/Settings/APIKeys/Widgets/ApiKeysList.php @@ -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') diff --git a/app/Web/Pages/Settings/NotificationChannels/Widgets/NotificationChannelsList.php b/app/Web/Pages/Settings/NotificationChannels/Widgets/NotificationChannelsList.php index 57cf388..3416849 100644 --- a/app/Web/Pages/Settings/NotificationChannels/Widgets/NotificationChannelsList.php +++ b/app/Web/Pages/Settings/NotificationChannels/Widgets/NotificationChannelsList.php @@ -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') diff --git a/app/Web/Pages/Settings/Profile/Widgets/ProfileInformation.php b/app/Web/Pages/Settings/Profile/Widgets/ProfileInformation.php index 1f3b53e..8e7321a 100644 --- a/app/Web/Pages/Settings/Profile/Widgets/ProfileInformation.php +++ b/app/Web/Pages/Settings/Profile/Widgets/ProfileInformation.php @@ -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,36 +34,37 @@ 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 [ - Section::make() - ->heading('Profile Information') - ->description('Update your account\'s profile information and email address.') - ->schema([ - TextInput::make('name') - ->label('Name') - ->rules($rules['name']), - TextInput::make('email') - ->label('Email') - ->rules($rules['email']), - Select::make('timezone') - ->label('Timezone') - ->searchable() - ->options( - collect(timezone_identifiers_list()) - ->mapWithKeys(fn ($timezone) => [$timezone => $timezone]) - ) - ->rules($rules['timezone']), - ]) - ->footerActions([ - Action::make('save') - ->label('Save') - ->action(fn () => $this->submit()), - ]), - ]; + return $form + ->schema([ + Section::make() + ->heading('Profile Information') + ->description('Update your account\'s profile information and email address.') + ->schema([ + TextInput::make('name') + ->label('Name') + ->rules($rules['name']), + TextInput::make('email') + ->label('Email') + ->rules($rules['email']), + Select::make('timezone') + ->label('Timezone') + ->searchable() + ->options( + collect(timezone_identifiers_list()) + ->mapWithKeys(fn ($timezone) => [$timezone => $timezone]) + ) + ->rules($rules['timezone']), + ]) + ->footerActions([ + Action::make('save') + ->label('Save') + ->action(fn () => $this->submit()), + ]), + ]); } public function submit(): void diff --git a/app/Web/Pages/Settings/Profile/Widgets/UpdatePassword.php b/app/Web/Pages/Settings/Profile/Widgets/UpdatePassword.php index 790f204..4dc7cc0 100644 --- a/app/Web/Pages/Settings/Profile/Widgets/UpdatePassword.php +++ b/app/Web/Pages/Settings/Profile/Widgets/UpdatePassword.php @@ -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,34 +26,35 @@ class UpdatePassword extends Widget implements HasForms public string $password_confirmation = ''; - public function getFormSchema(): array + public function form(Form $form): Form { $rules = UpdateUserPassword::rules(); - return [ - Section::make() - ->heading('Update Password') - ->description('Ensure your account is using a long, random password to stay secure.') - ->schema([ - TextInput::make('current_password') - ->label('Current Password') - ->password() - ->rules($rules['current_password']), - TextInput::make('password') - ->label('New Password') - ->password() - ->rules($rules['password']), - TextInput::make('password_confirmation') - ->label('Confirm Password') - ->password() - ->rules($rules['password_confirmation']), - ]) - ->footerActions([ - Action::make('save') - ->label('Save') - ->action(fn () => $this->submit()), - ]), - ]; + return $form + ->schema([ + Section::make() + ->heading('Update Password') + ->description('Ensure your account is using a long, random password to stay secure.') + ->schema([ + TextInput::make('current_password') + ->label('Current Password') + ->password() + ->rules($rules['current_password']), + TextInput::make('password') + ->label('New Password') + ->password() + ->rules($rules['password']), + TextInput::make('password_confirmation') + ->label('Confirm Password') + ->password() + ->rules($rules['password_confirmation']), + ]) + ->footerActions([ + Action::make('save') + ->label('Save') + ->action(fn () => $this->submit()), + ]), + ]); } public function submit(): void diff --git a/app/Web/Pages/Settings/Projects/Widgets/AddUser.php b/app/Web/Pages/Settings/Projects/Widgets/AddUser.php index 0a3c8e8..7fef69d 100644 --- a/app/Web/Pages/Settings/Projects/Widgets/AddUser.php +++ b/app/Web/Pages/Settings/Projects/Widgets/AddUser.php @@ -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,24 +28,25 @@ public function mount(Project $project): void $this->project = $project; } - public function getFormSchema(): array + public function form(Form $form): Form { - return [ - Section::make() - ->heading('Add User') - ->schema([ - Select::make('user') - ->name('user') - ->options(fn () => User::query()->pluck('name', 'id')) - ->searchable() - ->rules(\App\Actions\Projects\AddUser::rules($this->project)['user']), - ]) - ->footerActions([ - Action::make('add') - ->label('Add') - ->action(fn () => $this->submit()), - ]), - ]; + return $form + ->schema([ + Section::make() + ->heading('Add User') + ->schema([ + Select::make('user') + ->name('user') + ->options(fn () => User::query()->pluck('name', 'id')) + ->searchable() + ->rules(\App\Actions\Projects\AddUser::rules($this->project)['user']), + ]) + ->footerActions([ + Action::make('add') + ->label('Add') + ->action(fn () => $this->submit()), + ]), + ]); } public function submit(): void diff --git a/app/Web/Pages/Settings/Projects/Widgets/ProjectUsersList.php b/app/Web/Pages/Settings/Projects/Widgets/ProjectUsersList.php index 92cb871..95fa8cd 100644 --- a/app/Web/Pages/Settings/Projects/Widgets/ProjectUsersList.php +++ b/app/Web/Pages/Settings/Projects/Widgets/ProjectUsersList.php @@ -36,18 +36,23 @@ protected function getTableColumns(): array ]; } - public function getTable(): Table + public function table(Table $table): Table { - return $this->table->actions([ - Tables\Actions\DeleteAction::make() - ->label('Remove') - ->modalHeading('Remove user from project') - ->visible(function ($record) { - return $this->authorize('update', $this->project)->allowed() && $record->id !== auth()->id(); - }) - ->using(function ($record) { - $this->project->users()->detach($record); - }), - ])->paginated(false); + return $table + ->heading(null) + ->query($this->getTableQuery()) + ->columns($this->getTableColumns()) + ->actions([ + Tables\Actions\DeleteAction::make() + ->label('Remove') + ->modalHeading('Remove user from project') + ->visible(function ($record) { + return $this->authorize('update', $this->project)->allowed() && $record->id !== auth()->id(); + }) + ->using(function ($record) { + $this->project->users()->detach($record); + }), + ]) + ->paginated(false); } } diff --git a/app/Web/Pages/Settings/Projects/Widgets/ProjectsList.php b/app/Web/Pages/Settings/Projects/Widgets/ProjectsList.php index 094a017..9f0cf18 100644 --- a/app/Web/Pages/Settings/Projects/Widgets/ProjectsList.php +++ b/app/Web/Pages/Settings/Projects/Widgets/ProjectsList.php @@ -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') diff --git a/app/Web/Pages/Settings/Projects/Widgets/UpdateProject.php b/app/Web/Pages/Settings/Projects/Widgets/UpdateProject.php index 1e73eb9..12d6206 100644 --- a/app/Web/Pages/Settings/Projects/Widgets/UpdateProject.php +++ b/app/Web/Pages/Settings/Projects/Widgets/UpdateProject.php @@ -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,24 +28,25 @@ public function mount(Project $project): void $this->name = $project->name; } - public function getFormSchema(): array + public function form(Form $form): Form { - return [ - Section::make() - ->heading('Project Information') - ->schema([ - TextInput::make('name') - ->name('name') - ->label('Name') - ->rules(\App\Actions\Projects\UpdateProject::rules($this->project)['name']) - ->placeholder('Enter the project name'), - ]) - ->footerActions([ - Action::make('save') - ->label('Save') - ->action(fn () => $this->submit()), - ]), - ]; + return $form + ->schema([ + Section::make() + ->heading('Project Information') + ->schema([ + TextInput::make('name') + ->name('name') + ->label('Name') + ->rules(\App\Actions\Projects\UpdateProject::rules($this->project)['name']) + ->placeholder('Enter the project name'), + ]) + ->footerActions([ + Action::make('save') + ->label('Save') + ->action(fn () => $this->submit()), + ]), + ]); } public function submit(): void diff --git a/app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php b/app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php index 2a7e5ef..1d3d394 100644 --- a/app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php +++ b/app/Web/Pages/Settings/SSHKeys/Widgets/SshKeysList.php @@ -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() diff --git a/app/Web/Pages/Settings/ServerProviders/Widgets/ServerProvidersList.php b/app/Web/Pages/Settings/ServerProviders/Widgets/ServerProvidersList.php index d8adec8..d41a88f 100644 --- a/app/Web/Pages/Settings/ServerProviders/Widgets/ServerProvidersList.php +++ b/app/Web/Pages/Settings/ServerProviders/Widgets/ServerProvidersList.php @@ -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,36 +51,40 @@ protected function getTableColumns(): array ]; } - public function getTable(): Table + public function table(Table $table): Table { - return $this->table->actions([ - EditAction::make('edit') - ->label('Edit') - ->modalHeading('Edit Server Provider') - ->mutateRecordDataUsing(function (array $data, ServerProvider $record) { - return [ - 'name' => $record->profile, - 'global' => $record->project_id === null, - ]; - }) - ->form(Edit::form()) - ->authorize(fn (ServerProvider $record) => auth()->user()->can('update', $record)) - ->using(fn (array $data, ServerProvider $record) => Edit::action($record, $data)) - ->modalWidth(MaxWidth::Medium), - DeleteAction::make('delete') - ->label('Delete') - ->modalHeading('Delete Server Provider') - ->authorize(fn (ServerProvider $record) => auth()->user()->can('delete', $record)) - ->using(function (array $data, ServerProvider $record) { - try { - app(DeleteServerProvider::class)->delete($record); - } catch (Exception $e) { - Notification::make() - ->danger() - ->title($e->getMessage()) - ->send(); - } - }), - ]); + return $table + ->heading(null) + ->query($this->getTableQuery()) + ->columns($this->getTableColumns()) + ->actions([ + EditAction::make('edit') + ->label('Edit') + ->modalHeading('Edit Server Provider') + ->mutateRecordDataUsing(function (array $data, ServerProvider $record) { + return [ + 'name' => $record->profile, + 'global' => $record->project_id === null, + ]; + }) + ->form(Edit::form()) + ->authorize(fn (ServerProvider $record) => auth()->user()->can('update', $record)) + ->using(fn (array $data, ServerProvider $record) => Edit::action($record, $data)) + ->modalWidth(MaxWidth::Medium), + DeleteAction::make('delete') + ->label('Delete') + ->modalHeading('Delete Server Provider') + ->authorize(fn (ServerProvider $record) => auth()->user()->can('delete', $record)) + ->using(function (array $data, ServerProvider $record) { + try { + app(DeleteServerProvider::class)->delete($record); + } catch (Exception $e) { + Notification::make() + ->danger() + ->title($e->getMessage()) + ->send(); + } + }), + ]); } } diff --git a/app/Web/Pages/Settings/SourceControls/Widgets/SourceControlsList.php b/app/Web/Pages/Settings/SourceControls/Widgets/SourceControlsList.php index 46c9bff..58df6ab 100644 --- a/app/Web/Pages/Settings/SourceControls/Widgets/SourceControlsList.php +++ b/app/Web/Pages/Settings/SourceControls/Widgets/SourceControlsList.php @@ -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,45 +51,49 @@ protected function getTableColumns(): array ]; } - public function getTable(): Table + public function table(Table $table): Table { - return $this->table->actions([ - EditAction::make('edit') - ->label('Edit') - ->modalHeading('Edit Source Control') - ->fillForm(function (array $data, SourceControl $record) { - return [ - 'provider' => $record->provider, - 'name' => $record->profile, - 'token' => $record->provider_data['token'] ?? null, - 'username' => $record->provider_data['username'] ?? null, - 'password' => $record->provider_data['password'] ?? null, - 'global' => $record->project_id === null, - ]; - }) - ->form(fn (SourceControl $record) => Edit::form($record)) - ->authorize(fn (SourceControl $record) => auth()->user()->can('update', $record)) - ->using(fn (array $data, SourceControl $record) => Edit::action($record, $data)) - ->modalWidth(MaxWidth::Medium), - Action::make('delete') - ->label('Delete') - ->icon('heroicon-o-trash') - ->color('danger') - ->requiresConfirmation() - ->modalHeading('Delete Source Control') - ->authorize(fn (SourceControl $record) => auth()->user()->can('delete', $record)) - ->action(function (array $data, SourceControl $record) { - try { - app(DeleteSourceControl::class)->delete($record); + return $table + ->heading(null) + ->query($this->getTableQuery()) + ->columns($this->getTableColumns()) + ->actions([ + EditAction::make('edit') + ->label('Edit') + ->modalHeading('Edit Source Control') + ->fillForm(function (array $data, SourceControl $record) { + return [ + 'provider' => $record->provider, + 'name' => $record->profile, + 'token' => $record->provider_data['token'] ?? null, + 'username' => $record->provider_data['username'] ?? null, + 'password' => $record->provider_data['password'] ?? null, + 'global' => $record->project_id === null, + ]; + }) + ->form(fn (SourceControl $record) => Edit::form($record)) + ->authorize(fn (SourceControl $record) => auth()->user()->can('update', $record)) + ->using(fn (array $data, SourceControl $record) => Edit::action($record, $data)) + ->modalWidth(MaxWidth::Medium), + Action::make('delete') + ->label('Delete') + ->icon('heroicon-o-trash') + ->color('danger') + ->requiresConfirmation() + ->modalHeading('Delete Source Control') + ->authorize(fn (SourceControl $record) => auth()->user()->can('delete', $record)) + ->action(function (array $data, SourceControl $record) { + try { + app(DeleteSourceControl::class)->delete($record); - $this->dispatch('$refresh'); - } catch (Exception $e) { - Notification::make() - ->danger() - ->title($e->getMessage()) - ->send(); - } - }), - ]); + $this->dispatch('$refresh'); + } catch (Exception $e) { + Notification::make() + ->danger() + ->title($e->getMessage()) + ->send(); + } + }), + ]); } } diff --git a/app/Web/Pages/Settings/StorageProviders/Widgets/StorageProvidersList.php b/app/Web/Pages/Settings/StorageProviders/Widgets/StorageProvidersList.php index 3a4d7bf..2635d0a 100644 --- a/app/Web/Pages/Settings/StorageProviders/Widgets/StorageProvidersList.php +++ b/app/Web/Pages/Settings/StorageProviders/Widgets/StorageProvidersList.php @@ -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,36 +51,40 @@ protected function getTableColumns(): array ]; } - public function getTable(): Table + public function table(Table $table): Table { - return $this->table->actions([ - EditAction::make('edit') - ->label('Edit') - ->modalHeading('Edit Storage Provider') - ->mutateRecordDataUsing(function (array $data, StorageProvider $record) { - return [ - 'name' => $record->profile, - 'global' => $record->project_id === null, - ]; - }) - ->form(Edit::form()) - ->authorize(fn (StorageProvider $record) => auth()->user()->can('update', $record)) - ->using(fn (array $data, StorageProvider $record) => Edit::action($record, $data)) - ->modalWidth(MaxWidth::Medium), - DeleteAction::make('delete') - ->label('Delete') - ->modalHeading('Delete Storage Provider') - ->authorize(fn (StorageProvider $record) => auth()->user()->can('delete', $record)) - ->using(function (array $data, StorageProvider $record) { - try { - app(DeleteStorageProvider::class)->delete($record); - } catch (\Exception $e) { - Notification::make() - ->danger() - ->title($e->getMessage()) - ->send(); - } - }), - ]); + return $table + ->heading(null) + ->query($this->getTableQuery()) + ->columns($this->getTableColumns()) + ->actions([ + EditAction::make('edit') + ->label('Edit') + ->modalHeading('Edit Storage Provider') + ->mutateRecordDataUsing(function (array $data, StorageProvider $record) { + return [ + 'name' => $record->profile, + 'global' => $record->project_id === null, + ]; + }) + ->form(Edit::form()) + ->authorize(fn (StorageProvider $record) => auth()->user()->can('update', $record)) + ->using(fn (array $data, StorageProvider $record) => Edit::action($record, $data)) + ->modalWidth(MaxWidth::Medium), + DeleteAction::make('delete') + ->label('Delete') + ->modalHeading('Delete Storage Provider') + ->authorize(fn (StorageProvider $record) => auth()->user()->can('delete', $record)) + ->using(function (array $data, StorageProvider $record) { + try { + app(DeleteStorageProvider::class)->delete($record); + } catch (\Exception $e) { + Notification::make() + ->danger() + ->title($e->getMessage()) + ->send(); + } + }), + ]); } } diff --git a/app/Web/Pages/Settings/Tags/Widgets/TagsList.php b/app/Web/Pages/Settings/Tags/Widgets/TagsList.php index 65c1f64..b0a9aba 100644 --- a/app/Web/Pages/Settings/Tags/Widgets/TagsList.php +++ b/app/Web/Pages/Settings/Tags/Widgets/TagsList.php @@ -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([ diff --git a/app/Web/Pages/Settings/Users/Widgets/UsersList.php b/app/Web/Pages/Settings/Users/Widgets/UsersList.php index 59e8758..a981a2b 100644 --- a/app/Web/Pages/Settings/Users/Widgets/UsersList.php +++ b/app/Web/Pages/Settings/Users/Widgets/UsersList.php @@ -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))