From ee5840227fbde1445083d0287bc188bbf3545b2d Mon Sep 17 00:00:00 2001 From: Ahmed Darrazi Date: Fri, 20 Feb 2026 00:29:21 +0100 Subject: [PATCH] refactor: use Infolist for BaselineProfile view page Replace disabled form fields with proper Infolist (TextEntry, Section) on the ViewBaselineProfile page. Adds three sections: Profile (name, status badge, version, description), Scope (policy types as badges), and Metadata (created by, last snapshot, timestamps). --- .../Resources/BaselineProfileResource.php | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/app/Filament/Resources/BaselineProfileResource.php b/app/Filament/Resources/BaselineProfileResource.php index 23ad4b1..aea3d14 100644 --- a/app/Filament/Resources/BaselineProfileResource.php +++ b/app/Filament/Resources/BaselineProfileResource.php @@ -28,6 +28,8 @@ use Filament\Forms\Components\Select; use Filament\Forms\Components\Textarea; use Filament\Forms\Components\TextInput; +use Filament\Infolists\Components\Section; +use Filament\Infolists\Components\TextEntry; use Filament\Notifications\Notification; use Filament\Resources\Resource; use Filament\Schemas\Schema; @@ -165,6 +167,59 @@ public static function form(Schema $schema): Schema ]); } + public static function infolist(Schema $schema): Schema + { + return $schema + ->schema([ + Section::make('Profile') + ->schema([ + TextEntry::make('name'), + TextEntry::make('status') + ->badge() + ->formatStateUsing(BadgeRenderer::label(BadgeDomain::BaselineProfileStatus)) + ->color(BadgeRenderer::color(BadgeDomain::BaselineProfileStatus)) + ->icon(BadgeRenderer::icon(BadgeDomain::BaselineProfileStatus)), + TextEntry::make('version_label') + ->label('Version') + ->placeholder('—'), + TextEntry::make('description') + ->placeholder('No description') + ->columnSpanFull(), + ]) + ->columns(2) + ->columnSpanFull(), + Section::make('Scope') + ->schema([ + TextEntry::make('scope_jsonb.policy_types') + ->label('Policy type scope') + ->badge() + ->formatStateUsing(function (string $state): string { + $options = self::policyTypeOptions(); + + return $options[$state] ?? $state; + }) + ->placeholder('All policy types'), + ]) + ->columnSpanFull(), + Section::make('Metadata') + ->schema([ + TextEntry::make('createdByUser.name') + ->label('Created by') + ->placeholder('—'), + TextEntry::make('activeSnapshot.captured_at') + ->label('Last snapshot') + ->dateTime() + ->placeholder('No snapshot yet'), + TextEntry::make('created_at') + ->dateTime(), + TextEntry::make('updated_at') + ->dateTime(), + ]) + ->columns(2) + ->columnSpanFull(), + ]); + } + public static function table(Table $table): Table { $workspace = self::resolveWorkspace();