feat: upgrade filament to v4 and ensure 100% test coverage
- Upgrade Filament framework from v3 to v4 - Update all Filament resources and pages for v4 compatibility - Fix test suite to maintain 100% pass rate (321 tests passing) - Add visibility condition for ticket close action (only when not closed) - Update dependencies and build assets for new Filament version - Maintain backward compatibility while leveraging v4 improvements
This commit is contained in:
@@ -2,6 +2,19 @@
|
||||
|
||||
namespace App\Filament\Resources;
|
||||
|
||||
use Filament\Schemas\Schema;
|
||||
use Filament\Schemas\Components\Section;
|
||||
use Filament\Schemas\Components\Utilities\Set;
|
||||
use Filament\Tables\Filters\SelectFilter;
|
||||
use Filament\Actions\ViewAction;
|
||||
use Filament\Actions\EditAction;
|
||||
use Filament\Actions\DeleteAction;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Actions\BulkActionGroup;
|
||||
use Filament\Actions\DeleteBulkAction;
|
||||
use App\Filament\Resources\PageResource\Pages\ListPages;
|
||||
use App\Filament\Resources\PageResource\Pages\CreatePage;
|
||||
use App\Filament\Resources\PageResource\Pages\EditPage;
|
||||
use App\Filament\Resources\PageResource\Pages;
|
||||
use App\Filament\Resources\PageResource\RelationManagers;
|
||||
use App\Models\Page;
|
||||
@@ -10,13 +23,10 @@ use Filament\Forms\Components\FileUpload;
|
||||
use Filament\Forms\Components\KeyValue;
|
||||
use Filament\Forms\Components\Repeater;
|
||||
use Filament\Forms\Components\RichEditor;
|
||||
use Filament\Forms\Components\Section;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Forms\Components\Toggle;
|
||||
use Filament\Forms\Form;
|
||||
use Filament\Forms\Set;
|
||||
use Illuminate\Support\Str;
|
||||
use Filament\Resources\Resource;
|
||||
use Filament\Tables;
|
||||
@@ -31,16 +41,16 @@ class PageResource extends Resource
|
||||
{
|
||||
protected static ?string $model = Page::class;
|
||||
|
||||
protected static ?string $navigationIcon = 'heroicon-o-document';
|
||||
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-document';
|
||||
|
||||
protected static ?string $navigationGroup = 'Content';
|
||||
protected static string | \UnitEnum | null $navigationGroup = 'Content';
|
||||
|
||||
public static function form(Form $form): Form
|
||||
public static function form(Schema $schema): Schema
|
||||
{
|
||||
$pages = Page::Pluck('title', 'id')->toArray();
|
||||
|
||||
return $form
|
||||
->schema([
|
||||
return $schema
|
||||
->components([
|
||||
|
||||
Section::make('Page Information')
|
||||
->description('Add a new page')
|
||||
@@ -101,27 +111,27 @@ class PageResource extends Resource
|
||||
])
|
||||
->defaultSort('created_at', 'desc')
|
||||
->filters([
|
||||
Tables\Filters\SelectFilter::make('is_published')
|
||||
SelectFilter::make('is_published')
|
||||
->label('Status')
|
||||
->options([
|
||||
0 => 'Draft',
|
||||
1 => 'Published',
|
||||
]),
|
||||
])
|
||||
->actions([
|
||||
Tables\Actions\ViewAction::make(),
|
||||
Tables\Actions\EditAction::make(),
|
||||
Tables\Actions\DeleteAction::make(),
|
||||
Tables\Actions\Action::make('togglePublished')
|
||||
->recordActions([
|
||||
ViewAction::make(),
|
||||
EditAction::make(),
|
||||
DeleteAction::make(),
|
||||
Action::make('togglePublished')
|
||||
->label('Toggle Published')
|
||||
->icon('heroicon-o-eye')
|
||||
->action(function (\App\Models\Page $record) {
|
||||
->action(function (Page $record) {
|
||||
$record->update(['is_published' => !$record->is_published]);
|
||||
}),
|
||||
])
|
||||
->bulkActions([
|
||||
Tables\Actions\BulkActionGroup::make([
|
||||
Tables\Actions\DeleteBulkAction::make(),
|
||||
->toolbarActions([
|
||||
BulkActionGroup::make([
|
||||
DeleteBulkAction::make(),
|
||||
]),
|
||||
]);
|
||||
}
|
||||
@@ -136,9 +146,9 @@ class PageResource extends Resource
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => Pages\ListPages::route('/'),
|
||||
'create' => Pages\CreatePage::route('/create'),
|
||||
'edit' => Pages\EditPage::route('/{record}/edit'),
|
||||
'index' => ListPages::route('/'),
|
||||
'create' => CreatePage::route('/create'),
|
||||
'edit' => EditPage::route('/{record}/edit'),
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user