Skip to content

Commit 47f93e0

Browse files
committed
cleanup and fix some actions
1 parent f80b95d commit 47f93e0

File tree

22 files changed

+86
-126
lines changed

22 files changed

+86
-126
lines changed

announcements/src/Filament/Admin/Resources/Announcements/AnnouncementResource.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
use Boy132\Announcements\Filament\Admin\Resources\Announcements\Pages\ManageAnnouncements;
66
use Boy132\Announcements\Models\Announcement;
7+
use Filament\Actions\CreateAction;
78
use Filament\Actions\DeleteAction;
89
use Filament\Actions\EditAction;
910
use Filament\Actions\ViewAction;
@@ -70,10 +71,14 @@ public static function table(Table $table): Table
7071
])
7172
->recordActions([
7273
ViewAction::make()
73-
->hidden(fn ($record) => static::canEdit($record)),
74+
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
7475
EditAction::make(),
7576
DeleteAction::make(),
7677
])
78+
->toolbarActions([
79+
CreateAction::make()
80+
->createAnother(false),
81+
])
7782
->emptyStateIcon('tabler-speakerphone')
7883
->emptyStateDescription('')
7984
->emptyStateHeading(trans('announcements::strings.no_announcements'));

announcements/src/Filament/Admin/Resources/Announcements/Pages/ManageAnnouncements.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
namespace Boy132\Announcements\Filament\Admin\Resources\Announcements\Pages;
44

55
use Boy132\Announcements\Filament\Admin\Resources\Announcements\AnnouncementResource;
6-
use Filament\Actions\CreateAction;
76
use Filament\Resources\Pages\ManageRecords;
87

98
class ManageAnnouncements extends ManageRecords
109
{
1110
protected static string $resource = AnnouncementResource::class;
12-
13-
protected function getHeaderActions(): array
14-
{
15-
return [
16-
CreateAction::make()
17-
->createAnother(false)
18-
->hiddenLabel()
19-
->icon('tabler-plus'),
20-
];
21-
}
2211
}

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/GenericOIDCProviderResource.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages\EditGenericOIDCProvider;
88
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages\ListGenericOIDCProviders;
99
use Boy132\GenericOIDCProviders\Models\GenericOIDCProvider;
10+
use Filament\Actions\BulkActionGroup;
11+
use Filament\Actions\CreateAction;
1012
use Filament\Actions\DeleteAction;
1113
use Filament\Actions\DeleteBulkAction;
1214
use Filament\Actions\EditAction;
@@ -192,7 +194,10 @@ public static function table(Table $table): Table
192194
DeleteAction::make(),
193195
])
194196
->toolbarActions([
195-
DeleteBulkAction::make(),
197+
CreateAction::make(),
198+
BulkActionGroup::make([
199+
DeleteBulkAction::make('exclude_bulk_delete'),
200+
]),
196201
])
197202
->emptyStateIcon('tabler-brand-oauth')
198203
->emptyStateDescription('')

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/CreateGenericOIDCProvider.php

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,10 @@ class CreateGenericOIDCProvider extends CreateRecord
1616
protected function getHeaderActions(): array
1717
{
1818
return [
19-
Action::make('create')
19+
$this->getCreateFormAction()->formId('form')
20+
->tooltip(fn (Action $action) => $action->getLabel())
2021
->hiddenLabel()
21-
->action('create')
22-
->keyBindings(['mod+s'])
23-
->tooltip(trans('filament-panels::resources/pages/create-record.form.actions.create.label'))
24-
->icon('tabler-file-plus'),
22+
->icon('tabler-plus'),
2523
];
2624
}
2725

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/EditGenericOIDCProvider.php

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,14 @@ protected function getFormActions(): array
1919
protected function getHeaderActions(): array
2020
{
2121
return [
22+
$this->getCancelFormAction()->formId('form')
23+
->tooltip(fn (Action $action) => $action->getLabel())
24+
->hiddenLabel()
25+
->icon('tabler-arrow-left'),
2226
DeleteAction::make(),
23-
Action::make('save')
27+
$this->getSaveFormAction()->formId('form')
28+
->tooltip(fn (Action $action) => $action->getLabel())
2429
->hiddenLabel()
25-
->action('save')
26-
->keyBindings(['mod+s'])
27-
->tooltip(trans('filament-panels::resources/pages/edit-record.form.actions.save.label'))
2830
->icon('tabler-device-floppy'),
2931
];
3032
}

generic-oidc-providers/src/Filament/Admin/Resources/GenericOIDCProviders/Pages/ListGenericOIDCProviders.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
namespace Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\Pages;
44

55
use Boy132\GenericOIDCProviders\Filament\Admin\Resources\GenericOIDCProviders\GenericOIDCProviderResource;
6-
use Filament\Actions\CreateAction;
76
use Filament\Resources\Pages\ListRecords;
87

98
class ListGenericOIDCProviders extends ListRecords
109
{
1110
protected static string $resource = GenericOIDCProviderResource::class;
12-
13-
protected function getHeaderActions(): array
14-
{
15-
return [
16-
CreateAction::make()
17-
->createAnother(false)
18-
->hiddenLabel()
19-
->icon('tabler-plus'),
20-
];
21-
}
2211
}

player-counter/src/Filament/Admin/Resources/GameQueries/GameQueryResource.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Boy132\PlayerCounter\Extensions\Query\QueryTypeService;
66
use Boy132\PlayerCounter\Filament\Admin\Resources\GameQueries\Pages\ManageGameQueries;
77
use Boy132\PlayerCounter\Models\GameQuery;
8+
use Filament\Actions\CreateAction;
89
use Filament\Actions\DeleteAction;
910
use Filament\Actions\EditAction;
1011
use Filament\Actions\ViewAction;
@@ -61,10 +62,14 @@ public static function table(Table $table): Table
6162
])
6263
->recordActions([
6364
ViewAction::make()
64-
->hidden(fn ($record) => static::canEdit($record)),
65+
->hidden(fn ($record) => static::getEditAuthorizationResponse($record)->allowed()),
6566
EditAction::make(),
6667
DeleteAction::make(),
6768
])
69+
->toolbarActions([
70+
CreateAction::make()
71+
->createAnother(false),
72+
])
6873
->emptyStateIcon('tabler-device-desktop-search')
6974
->emptyStateDescription('')
7075
->emptyStateHeading(trans('player-counter::query.no_queries'));

player-counter/src/Filament/Admin/Resources/GameQueries/Pages/ManageGameQueries.php

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,9 @@
33
namespace Boy132\PlayerCounter\Filament\Admin\Resources\GameQueries\Pages;
44

55
use Boy132\PlayerCounter\Filament\Admin\Resources\GameQueries\GameQueryResource;
6-
use Filament\Actions\CreateAction;
76
use Filament\Resources\Pages\ManageRecords;
87

98
class ManageGameQueries extends ManageRecords
109
{
1110
protected static string $resource = GameQueryResource::class;
12-
13-
protected function getHeaderActions(): array
14-
{
15-
return [
16-
CreateAction::make()
17-
->createAnother(false)
18-
->hiddenLabel()
19-
->icon('tabler-plus'),
20-
];
21-
}
2211
}

subdomains/src/Filament/Admin/Resources/CloudflareDomains/CloudflareDomainResource.php

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
use Boy132\Subdomains\Models\CloudflareDomain;
77
use Exception;
88
use Filament\Actions\Action;
9+
use Filament\Actions\CreateAction;
910
use Filament\Actions\DeleteAction;
1011
use Filament\Forms\Components\TextInput;
1112
use Filament\Infolists\Components\TextEntry;
@@ -68,7 +69,7 @@ public static function table(Table $table): Table
6869
])
6970
->recordActions([
7071
Action::make('sync')
71-
->label(trans('subdomains::strings.sync'))
72+
->tooltip(trans('subdomains::strings.sync'))
7273
->icon('tabler-refresh')
7374
->visible(fn (CloudflareDomain $domain) => is_null($domain->cloudflare_id))
7475
->action(function (CloudflareDomain $domain) {
@@ -90,6 +91,23 @@ public static function table(Table $table): Table
9091
}),
9192
DeleteAction::make(),
9293
])
94+
->toolbarActions([
95+
CreateAction::make()
96+
->createAnother(false)
97+
//->hidden(fn () => is_null(config('subdomains.token')))
98+
->using(function (array $data) {
99+
try {
100+
return CloudflareDomain::create($data);
101+
} catch (Exception $exception) {
102+
Notification::make()
103+
->title(trans('subdomains::strings.notifications.not_synced'))
104+
->body($exception->getMessage())
105+
->warning()
106+
->persistent()
107+
->send();
108+
}
109+
}),
110+
])
93111
->emptyStateIcon('tabler-world-www')
94112
->emptyStateDescription('')
95113
->emptyStateHeading(trans('subdomains::strings.no_domains'));

subdomains/src/Filament/Admin/Resources/CloudflareDomains/Pages/ManageCloudflareDomains.php

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,36 +3,9 @@
33
namespace Boy132\Subdomains\Filament\Admin\Resources\CloudflareDomains\Pages;
44

55
use Boy132\Subdomains\Filament\Admin\Resources\CloudflareDomains\CloudflareDomainResource;
6-
use Boy132\Subdomains\Models\CloudflareDomain;
7-
use Exception;
8-
use Filament\Actions\CreateAction;
9-
use Filament\Notifications\Notification;
106
use Filament\Resources\Pages\ManageRecords;
117

128
class ManageCloudflareDomains extends ManageRecords
139
{
1410
protected static string $resource = CloudflareDomainResource::class;
15-
16-
protected function getHeaderActions(): array
17-
{
18-
return [
19-
CreateAction::make()
20-
->createAnother(false)
21-
->hiddenLabel()
22-
->icon('tabler-plus')
23-
->hidden(fn () => is_null(config('subdomains.token')))
24-
->using(function (array $data) {
25-
try {
26-
return CloudflareDomain::create($data);
27-
} catch (Exception $exception) {
28-
Notification::make()
29-
->title(trans('subdomains::strings.notifications.not_synced'))
30-
->body($exception->getMessage())
31-
->warning()
32-
->persistent()
33-
->send();
34-
}
35-
}),
36-
];
37-
}
3811
}

0 commit comments

Comments
 (0)