-
-
Notifications
You must be signed in to change notification settings - Fork 108
Expand file tree
/
Copy pathViewPlugin.php
More file actions
50 lines (44 loc) · 1.99 KB
/
ViewPlugin.php
File metadata and controls
50 lines (44 loc) · 1.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
namespace App\Filament\Resources\PluginResource\Pages;
use App\Filament\Resources\PluginResource;
use Filament\Actions;
use Filament\Forms;
use Filament\Resources\Pages\ViewRecord;
class ViewPlugin extends ViewRecord
{
protected static string $resource = PluginResource::class;
protected function getHeaderActions(): array
{
return [
Actions\Action::make('viewListing')
->label('View Listing Page')
->icon('heroicon-o-eye')
->color('gray')
->url(fn () => route('plugins.show', $this->record->routeParams()))
->openUrlInNewTab()
->visible(fn () => $this->record->isApproved() || $this->record->isPending()),
Actions\Action::make('approve')
->icon('heroicon-o-check')
->color('success')
->visible(fn () => $this->record->isPending())
->action(fn () => $this->record->approve(auth()->id()))
->requiresConfirmation()
->modalHeading('Approve Plugin')
->modalDescription(fn () => "Are you sure you want to approve '{$this->record->name}'?"),
Actions\Action::make('reject')
->icon('heroicon-o-x-mark')
->color('danger')
->visible(fn () => $this->record->isPending() || $this->record->isApproved())
->form([
Forms\Components\Textarea::make('rejection_reason')
->label('Reason for Rejection')
->required()
->rows(3)
->placeholder('Please explain why this plugin is being rejected...'),
])
->action(fn (array $data) => $this->record->reject($data['rejection_reason'], auth()->id()))
->modalHeading('Reject Plugin')
->modalDescription(fn () => "Are you sure you want to reject '{$this->record->name}'?"),
];
}
}