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:
idevakk
2025-11-14 01:42:07 -08:00
parent 3706072ce5
commit 3892c48ef2
103 changed files with 1741 additions and 890 deletions

View File

@@ -2,6 +2,8 @@
namespace App\Filament\Pages;
use Illuminate\Database\Eloquent\Builder;
use Filament\Actions\BulkAction;
use App\Models\ActivationKey;
use App\Models\Plan;
use Filament\Forms\Components\Select;
@@ -9,7 +11,6 @@ use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Pages\Page;
use Filament\Tables\Actions\BulkAction;
use Filament\Tables\Columns\BooleanColumn;
use Filament\Tables\Columns\TextColumn;
use Filament\Tables\Concerns\InteractsWithTable;
@@ -24,9 +25,9 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
{
use InteractsWithForms, InteractsWithTable;
protected static ?string $navigationIcon = 'heroicon-o-key';
protected static string $view = 'filament.pages.generate-activation-keys';
protected static ?string $navigationGroup = 'Admin';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-key';
protected string $view = 'filament.pages.generate-activation-keys';
protected static string | \UnitEnum | null $navigationGroup = 'Admin';
protected static ?string $title = 'Activation Keys';
public $plan_id;
@@ -75,7 +76,7 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
}
// === Table Setup ===
protected function getTableQuery(): \Illuminate\Database\Eloquent\Builder
protected function getTableQuery(): Builder
{
return ActivationKey::query()->latest();
}
@@ -95,7 +96,7 @@ class GenerateActivationKeys extends Page implements HasForms, HasTable
TextColumn::make('billing_interval')
->label('Interval')
->getStateUsing(function ($record) {
$isMonthly = \App\Models\Plan::where('pricing_id', $record->price_id)->value('monthly_billing');
$isMonthly = Plan::where('pricing_id', $record->price_id)->value('monthly_billing');
return $isMonthly ? 'Monthly' : 'Yearly';
}),

View File

@@ -2,21 +2,21 @@
namespace App\Filament\Pages;
use Filament\Schemas\Schema;
use Filament\Schemas\Components\Section;
use Exception;
use App\Models\Setting;
use App\Models\ZEmail;
use Artisan;
use Ddeboer\Imap\Server;
use Filament\Actions\Action;
use Filament\Forms\Components\Checkbox;
use Filament\Forms\Components\KeyValue;
use Filament\Forms\Components\Repeater;
use Filament\Forms\Components\Section;
use Filament\Forms\Components\Select;
use Filament\Forms\Components\Textarea;
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\Pages\Page;
@@ -26,11 +26,11 @@ class Settings extends Page implements HasForms
public ?array $data = [];
protected static ?string $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static string | \BackedEnum | null $navigationIcon = 'heroicon-o-cog-6-tooth';
protected static string $view = 'filament.pages.settings';
protected string $view = 'filament.pages.settings';
protected static ?string $navigationGroup = 'Web Master';
protected static string | \UnitEnum | null $navigationGroup = 'Web Master';
public function mount(): void
{
@@ -103,10 +103,10 @@ class Settings extends Page implements HasForms
}
}
public function form(Form $form): Form
public function form(Schema $schema): Schema
{
return $form
->schema([
return $schema
->components([
Section::make('Website Information')
->description('Change Basic Website Information')
->collapsible()
@@ -356,21 +356,7 @@ class Settings extends Page implements HasForms
->statePath('data');
}
protected function getFormActions(): array
{
return [
Action::make('save')
->label(__('filament-panels::resources/pages/edit-record.form.actions.save.label'))
->submit('save'),
Action::make('flushCache')
->label(__('Flush Cache'))
->color('danger')
->icon('heroicon-m-no-symbol')
->action('flushCache')
->requiresConfirmation(),
];
}
public function flushCache(): void
{
try {
@@ -379,7 +365,7 @@ class Settings extends Page implements HasForms
->title('Cache flushed successfully')
->success()
->send();
} catch (\Exception $e) {
} catch (Exception $e) {
Notification::make()
->title('Error : '.$e->getMessage())
->danger()
@@ -474,7 +460,7 @@ class Settings extends Page implements HasForms
->send();
}
}
} catch (\Exception $exception) {
} catch (Exception $exception) {
Notification::make()
->title('Something went wrong '.$exception->getMessage())
->danger()
@@ -514,7 +500,7 @@ class Settings extends Page implements HasForms
ZEmail::connectMailBox($imap);
return true;
} catch (\Exception $exception) {
} catch (Exception $exception) {
$errorMessage = $exception->getMessage();
// Provide more helpful error messages