Skip to content

Commit fb3b0e3

Browse files
svenvg93claudealexjustesen
authored
[Chore] Upgrade to Filament v4 (#2381)
Co-authored-by: Claude <[email protected]> Co-authored-by: Alex Justesen <[email protected]>
1 parent f0c659e commit fb3b0e3

File tree

96 files changed

+3000
-2008
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

96 files changed

+3000
-2008
lines changed

.github/copilot-instructions.md

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
88
## Foundational Context
99
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1010

11-
- php - 8.4.14
12-
- filament/filament (FILAMENT) - v3
11+
- php - 8.4.1
12+
- filament/filament (FILAMENT) - v4
1313
- laravel/framework (LARAVEL) - v12
1414
- laravel/prompts (PROMPTS) - v0
1515
- laravel/sanctum (SANCTUM) - v4
@@ -20,6 +20,7 @@ This application is a Laravel application and its main Laravel ecosystems packag
2020
- laravel/telescope (TELESCOPE) - v5
2121
- pestphp/pest (PEST) - v3
2222
- phpunit/phpunit (PHPUNIT) - v11
23+
- rector/rector (RECTOR) - v2
2324
- tailwindcss (TAILWINDCSS) - v3
2425

2526
## Conventions
@@ -196,19 +197,25 @@ Forms\Components\Select::make('user_id')
196197
</code-snippet>
197198

198199

199-
=== filament/v3 rules ===
200+
=== filament/v4 rules ===
200201

201-
## Filament 3
202+
## Filament 4
202203

203-
## Version 3 Changes To Focus On
204-
- Resources are located in `app/Filament/Resources/` directory.
205-
- Resource pages (List, Create, Edit) are auto-generated within the resource's directory - e.g., `app/Filament/Resources/PostResource/Pages/`.
206-
- Forms use the `Forms\Components` namespace for form fields.
207-
- Tables use the `Tables\Columns` namespace for table columns.
208-
- A new `Filament\Forms\Components\RichEditor` component is available.
209-
- Form and table schemas now use fluent method chaining.
210-
- Added `php artisan filament:optimize` command for production optimization.
211-
- Requires implementing `FilamentUser` contract for production access control.
204+
### Important Version 4 Changes
205+
- File visibility is now `private` by default.
206+
- The `deferFilters` method from Filament v3 is now the default behavior in Filament v4, so users must click a button before the filters are applied to the table. To disable this behavior, you can use the `deferFilters(false)` method.
207+
- The `Grid`, `Section`, and `Fieldset` layout components no longer span all columns by default.
208+
- The `all` pagination page method is not available for tables by default.
209+
- All action classes extend `Filament\Actions\Action`. No action classes exist in `Filament\Tables\Actions`.
210+
- The `Form` & `Infolist` layout components have been moved to `Filament\Schemas\Components`, for example `Grid`, `Section`, `Fieldset`, `Tabs`, `Wizard`, etc.
211+
- A new `Repeater` component for Forms has been added.
212+
- Icons now use the `Filament\Support\Icons\Heroicon` Enum by default. Other options are available and documented.
213+
214+
### Organize Component Classes Structure
215+
- Schema components: `Schemas/Components/`
216+
- Table columns: `Tables/Columns/`
217+
- Table filters: `Tables/Filters/`
218+
- Actions: `Actions/`
212219

213220

214221
=== laravel/core rules ===

.github/workflows/update-openapi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress
2727

2828
- name: Generate OpenAPI JSON
29-
run: ./vendor/bin/openapi app -o openapi_temp.json -f json
29+
run: ./vendor/bin/openapi ./app/Http/Controllers/Api ./app/OpenApi -o openapi_temp.json -f json
3030

3131
- name: Commit OpenAPI JSON if changed
3232
run: |

CLAUDE.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ The Laravel Boost guidelines are specifically curated by Laravel maintainers for
88
## Foundational Context
99
This application is a Laravel application and its main Laravel ecosystems package & versions are below. You are an expert with them all. Ensure you abide by these specific packages & versions.
1010

11-
- php - 8.4.14
12-
- filament/filament (FILAMENT) - v3
11+
- php - 8.4.1
12+
- filament/filament (FILAMENT) - v4
1313
- laravel/framework (LARAVEL) - v12
1414
- laravel/prompts (PROMPTS) - v0
1515
- laravel/sanctum (SANCTUM) - v4
@@ -20,18 +20,14 @@ This application is a Laravel application and its main Laravel ecosystems packag
2020
- laravel/telescope (TELESCOPE) - v5
2121
- pestphp/pest (PEST) - v3
2222
- phpunit/phpunit (PHPUNIT) - v11
23+
- rector/rector (RECTOR) - v2
2324
- tailwindcss (TAILWINDCSS) - v3
2425

2526
## Conventions
2627
- You must follow all existing code conventions used in this application. When creating or editing a file, check sibling files for the correct structure, approach, naming.
2728
- Use descriptive names for variables and methods. For example, `isRegisteredForDiscounts`, not `discount()`.
2829
- Check for existing components to reuse before writing a new one.
2930

30-
## Final Steps After All AI Work
31-
- **CRITICAL**: You must ALWAYS run `./vendor/bin/pint --dirty` after completing ALL code changes, edits, or additions. This ensures all PHP code matches the project's expected formatting style.
32-
- This is a mandatory final step for every task that involves PHP code modifications.
33-
- Run Pint before considering any work complete.
34-
3531
## Verification Scripts
3632
- Do not create verification scripts or tinker when tests cover that functionality and prove it works. Unit and feature tests are more important.
3733

@@ -201,19 +197,25 @@ Forms\Components\Select::make('user_id')
201197
</code-snippet>
202198

203199

204-
=== filament/v3 rules ===
200+
=== filament/v4 rules ===
201+
202+
## Filament 4
205203

206-
## Filament 3
204+
### Important Version 4 Changes
205+
- File visibility is now `private` by default.
206+
- The `deferFilters` method from Filament v3 is now the default behavior in Filament v4, so users must click a button before the filters are applied to the table. To disable this behavior, you can use the `deferFilters(false)` method.
207+
- The `Grid`, `Section`, and `Fieldset` layout components no longer span all columns by default.
208+
- The `all` pagination page method is not available for tables by default.
209+
- All action classes extend `Filament\Actions\Action`. No action classes exist in `Filament\Tables\Actions`.
210+
- The `Form` & `Infolist` layout components have been moved to `Filament\Schemas\Components`, for example `Grid`, `Section`, `Fieldset`, `Tabs`, `Wizard`, etc.
211+
- A new `Repeater` component for Forms has been added.
212+
- Icons now use the `Filament\Support\Icons\Heroicon` Enum by default. Other options are available and documented.
207213

208-
## Version 3 Changes To Focus On
209-
- Resources are located in `app/Filament/Resources/` directory.
210-
- Resource pages (List, Create, Edit) are auto-generated within the resource's directory - e.g., `app/Filament/Resources/PostResource/Pages/`.
211-
- Forms use the `Forms\Components` namespace for form fields.
212-
- Tables use the `Tables\Columns` namespace for table columns.
213-
- A new `Filament\Forms\Components\RichEditor` component is available.
214-
- Form and table schemas now use fluent method chaining.
215-
- Added `php artisan filament:optimize` command for production optimization.
216-
- Requires implementing `FilamentUser` contract for production access control.
214+
### Organize Component Classes Structure
215+
- Schema components: `Schemas/Components/`
216+
- Table columns: `Tables/Columns/`
217+
- Table filters: `Tables/Filters/`
218+
- Actions: `Actions/`
217219

218220

219221
=== laravel/core rules ===

app/Filament/Pages/Dashboard.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515

1616
class Dashboard extends BasePage
1717
{
18-
protected static ?string $navigationIcon = 'heroicon-o-chart-bar';
18+
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-chart-bar';
1919

20-
protected static string $view = 'filament.pages.dashboard';
20+
protected string $view = 'filament.pages.dashboard';
2121

2222
public function getSubheading(): ?string
2323
{
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
<?php
2+
3+
namespace App\Filament\Pages\Settings;
4+
5+
use App\Jobs\Influxdb\v2\BulkWriteResults;
6+
use App\Jobs\Influxdb\v2\TestConnectionJob;
7+
use App\Settings\DataIntegrationSettings;
8+
use Filament\Actions\Action;
9+
use Filament\Forms\Components\Checkbox;
10+
use Filament\Forms\Components\TextInput;
11+
use Filament\Forms\Components\Toggle;
12+
use Filament\Notifications\Notification;
13+
use Filament\Pages\SettingsPage;
14+
use Filament\Schemas\Components\Actions;
15+
use Filament\Schemas\Components\Grid;
16+
use Filament\Schemas\Components\Section;
17+
use Filament\Schemas\Components\Utilities\Get;
18+
use Filament\Schemas\Schema;
19+
use Illuminate\Support\Facades\Auth;
20+
21+
class DataIntegration extends SettingsPage
22+
{
23+
protected static string|\BackedEnum|null $navigationIcon = 'heroicon-o-circle-stack';
24+
25+
protected static string|\UnitEnum|null $navigationGroup = 'Settings';
26+
27+
protected static ?int $navigationSort = 2;
28+
29+
protected static ?string $title = 'Data Integration';
30+
31+
protected static ?string $navigationLabel = 'Data Integration';
32+
33+
protected static string $settings = DataIntegrationSettings::class;
34+
35+
public static function canAccess(): bool
36+
{
37+
return Auth::check() && Auth::user()->is_admin;
38+
}
39+
40+
public static function shouldRegisterNavigation(): bool
41+
{
42+
return Auth::check() && Auth::user()->is_admin;
43+
}
44+
45+
public function form(Schema $schema): Schema
46+
{
47+
return $schema
48+
->components([
49+
Grid::make([
50+
'default' => 1,
51+
'md' => 3,
52+
])
53+
->schema([
54+
Section::make('InfluxDB v2')
55+
->description('When enabled, all new Speedtest results will also be sent to InfluxDB.')
56+
->schema([
57+
Toggle::make('influxdb_v2_enabled')
58+
->label('Enable')
59+
->reactive()
60+
->columnSpanFull(),
61+
Grid::make(['default' => 1, 'md' => 3])
62+
->hidden(fn (Get $get) => $get('influxdb_v2_enabled') !== true)
63+
->schema([
64+
TextInput::make('influxdb_v2_url')
65+
->label('URL')
66+
->placeholder('http://your-influxdb-instance')
67+
->maxLength(255)
68+
->required(fn (Get $get) => $get('influxdb_v2_enabled') === true)
69+
->columnSpan(['md' => 1]),
70+
TextInput::make('influxdb_v2_org')
71+
->label('Org')
72+
->maxLength(255)
73+
->required(fn (Get $get) => $get('influxdb_v2_enabled') === true)
74+
->columnSpan(['md' => 1]),
75+
TextInput::make('influxdb_v2_bucket')
76+
->placeholder('speedtest-tracker')
77+
->label('Bucket')
78+
->maxLength(255)
79+
->required(fn (Get $get) => $get('influxdb_v2_enabled') === true)
80+
->columnSpan(['md' => 2]),
81+
TextInput::make('influxdb_v2_token')
82+
->label('Token')
83+
->maxLength(255)
84+
->password()
85+
->required(fn (Get $get) => $get('influxdb_v2_enabled') === true)
86+
->columnSpan(['md' => 2]),
87+
Checkbox::make('influxdb_v2_verify_ssl')
88+
->label('Verify SSL')
89+
->columnSpanFull(),
90+
// Button to send old data to InfluxDB
91+
Actions::make([
92+
Action::make('Export current results')
93+
->label('Export current results')
94+
->action(function () {
95+
Notification::make()
96+
->title('Starting bulk data write to Influxdb')
97+
->info()
98+
->send();
99+
100+
BulkWriteResults::dispatch(Auth::user());
101+
})
102+
->color('primary')
103+
->icon('heroicon-o-cloud-arrow-up')
104+
->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled),
105+
]),
106+
// Button to test InfluxDB connection
107+
Actions::make([
108+
Action::make('Test connection')
109+
->label('Test connection')
110+
->action(function () {
111+
Notification::make()
112+
->title('Sending test data to Influxdb')
113+
->info()
114+
->send();
115+
116+
TestConnectionJob::dispatch(Auth::user());
117+
})
118+
->color('primary')
119+
->icon('heroicon-o-check-circle')
120+
->visible(fn (): bool => app(DataIntegrationSettings::class)->influxdb_v2_enabled),
121+
]),
122+
]),
123+
])
124+
->compact()
125+
->columnSpanFull(),
126+
])
127+
->columnSpanFull(),
128+
]);
129+
}
130+
}

0 commit comments

Comments
 (0)