Skip to content

Commit 25e24a9

Browse files
simonhampclaude
andcommitted
Rework admin plugin edit: status badge in header, reorder fields, remove rejection reason
- Show status as a Filament badge in the page subheading using matching index colors - Reorder form: display name, description, type, tier, composer link, repo URL, license - Remove status and rejection_reason fields from the form - Add tests for status badge, removed fields Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent eefcb85 commit 25e24a9

3 files changed

Lines changed: 59 additions & 21 deletions

File tree

app/Filament/Resources/PluginResource.php

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,17 @@ public static function form(Schema $schema): Schema
5959
Forms\Components\TextInput::make('display_name')
6060
->label('Display Name'),
6161

62+
Forms\Components\Textarea::make('description')
63+
->label('Description'),
64+
65+
Forms\Components\Select::make('type')
66+
->options(PluginType::class),
67+
68+
Forms\Components\Select::make('tier')
69+
->options(PluginTier::class)
70+
->placeholder('No tier')
71+
->helperText('Set pricing tier for paid plugins'),
72+
6273
Forms\Components\Placeholder::make('name')
6374
->label('Composer Package Name')
6475
->content(function (?Plugin $record) {
@@ -73,14 +84,6 @@ public static function form(Schema $schema): Schema
7384
return $record->name;
7485
}),
7586

76-
Forms\Components\Select::make('type')
77-
->options(PluginType::class),
78-
79-
Forms\Components\Select::make('tier')
80-
->options(PluginTier::class)
81-
->placeholder('No tier')
82-
->helperText('Set pricing tier for paid plugins'),
83-
8487
Forms\Components\Placeholder::make('repository_url')
8588
->label('Repository URL')
8689
->content(fn (?Plugin $record) => $record?->repository_url
@@ -109,22 +112,9 @@ public static function form(Schema $schema): Schema
109112
})
110113
->visible(fn (?Plugin $record) => $record !== null),
111114

112-
Forms\Components\Select::make('status')
113-
->options(PluginStatus::class)
114-
->disabled()
115-
->helperText('Use the Approve/Reject actions to change status'),
116-
117115
Forms\Components\Toggle::make('is_official')
118116
->label('Official (First-Party)')
119117
->helperText('Official plugins are free for Ultra subscribers'),
120-
121-
Forms\Components\Textarea::make('description')
122-
->label('Description'),
123-
124-
Forms\Components\Textarea::make('rejection_reason')
125-
->label('Rejection Reason')
126-
127-
->visible(fn (?Plugin $record) => $record?->isRejected()),
128118
]),
129119

130120
Schemas\Components\Section::make('Review Checks')

app/Filament/Resources/PluginResource/Pages/EditPlugin.php

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace App\Filament\Resources\PluginResource\Pages;
44

5+
use App\Enums\PluginStatus;
56
use App\Enums\PluginTier;
67
use App\Enums\PluginType;
78
use App\Filament\Resources\PluginResource;
@@ -15,12 +16,30 @@
1516
use Filament\Forms;
1617
use Filament\Notifications\Notification;
1718
use Filament\Resources\Pages\EditRecord;
19+
use Illuminate\Support\Facades\Blade;
1820
use Illuminate\Support\HtmlString;
1921

2022
class EditPlugin extends EditRecord
2123
{
2224
protected static string $resource = PluginResource::class;
2325

26+
public function getSubheading(): string|HtmlString|null
27+
{
28+
$color = match ($this->record->status) {
29+
PluginStatus::Draft => 'gray',
30+
PluginStatus::Pending => 'warning',
31+
PluginStatus::Approved => 'success',
32+
PluginStatus::Rejected => 'danger',
33+
};
34+
35+
return new HtmlString(
36+
Blade::render('<x-filament::badge :color="$color">{{ $label }}</x-filament::badge>', [
37+
'color' => $color,
38+
'label' => $this->record->status->label(),
39+
])
40+
);
41+
}
42+
2443
protected function getHeaderActions(): array
2544
{
2645
return [

tests/Feature/Filament/PluginEditFormTest.php

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,4 +105,33 @@ public function test_approve_action_is_hidden_for_approved_plugin(): void
105105
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
106106
->assertActionHidden('approve');
107107
}
108+
109+
public function test_status_is_shown_as_badge_in_subheading(): void
110+
{
111+
$plugin = Plugin::factory()->approved()->create();
112+
113+
Livewire::actingAs($this->admin)
114+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
115+
->assertSee('Approved');
116+
}
117+
118+
public function test_status_field_is_not_in_form(): void
119+
{
120+
$plugin = Plugin::factory()->approved()->create();
121+
122+
Livewire::actingAs($this->admin)
123+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
124+
->assertFormFieldDoesNotExist('status');
125+
}
126+
127+
public function test_rejection_reason_field_is_not_in_form(): void
128+
{
129+
$plugin = Plugin::factory()->rejected()->create([
130+
'rejection_reason' => 'Missing license',
131+
]);
132+
133+
Livewire::actingAs($this->admin)
134+
->test(EditPlugin::class, ['record' => $plugin->getRouteKey()])
135+
->assertFormFieldDoesNotExist('rejection_reason');
136+
}
108137
}

0 commit comments

Comments
 (0)