Skip to content

Commit 13b8de3

Browse files
committed
fix billing plugin actions
1 parent b1261a5 commit 13b8de3

17 files changed

Lines changed: 82 additions & 46 deletions

File tree

billing/src/Filament/Admin/Resources/Coupons/CouponResource.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
use Boy132\Billing\Filament\Admin\Resources\Coupons\Pages\EditCoupon;
99
use Boy132\Billing\Filament\Admin\Resources\Coupons\Pages\ListCoupons;
1010
use Boy132\Billing\Models\Coupon;
11+
use Filament\Actions\BulkActionGroup;
12+
use Filament\Actions\CreateAction;
1113
use Filament\Actions\DeleteAction;
1214
use Filament\Actions\DeleteBulkAction;
1315
use Filament\Actions\EditAction;
@@ -105,7 +107,11 @@ public static function table(Table $table): Table
105107
DeleteAction::make(),
106108
])
107109
->toolbarActions([
108-
DeleteBulkAction::make(),
110+
CreateAction::make()
111+
->createAnother(false),
112+
BulkActionGroup::make([
113+
DeleteBulkAction::make('exclude_bulk_delete'),
114+
]),
109115
])
110116
->emptyStateHeading('No Coupons')
111117
->emptyStateDescription('')

billing/src/Filament/Admin/Resources/Coupons/Pages/CreateCoupon.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Boy132\Billing\Filament\Admin\Resources\Coupons\Pages;
44

55
use Boy132\Billing\Filament\Admin\Resources\Coupons\CouponResource;
6+
use Filament\Actions\Action;
67
use Filament\Resources\Pages\CreateRecord;
78

89
class CreateCoupon extends CreateRecord
@@ -19,7 +20,10 @@ protected function getFormActions(): array
1920
protected function getHeaderActions(): array
2021
{
2122
return [
22-
$this->getCreateFormAction()->formId('form'),
23+
$this->getCreateFormAction()->formId('form')
24+
->tooltip(fn (Action $action) => $action->getLabel())
25+
->hiddenLabel()
26+
->icon('tabler-plus'),
2327
];
2428
}
2529
}

billing/src/Filament/Admin/Resources/Coupons/Pages/EditCoupon.php

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

55
use Boy132\Billing\Enums\CouponType;
66
use Boy132\Billing\Filament\Admin\Resources\Coupons\CouponResource;
7+
use Filament\Actions\Action;
78
use Filament\Actions\DeleteAction;
89
use Filament\Resources\Pages\EditRecord;
910

@@ -19,8 +20,15 @@ protected function getFormActions(): array
1920
protected function getHeaderActions(): array
2021
{
2122
return [
23+
$this->getCancelFormAction()->formId('form')
24+
->tooltip(fn (Action $action) => $action->getLabel())
25+
->hiddenLabel()
26+
->icon('tabler-arrow-left'),
2227
DeleteAction::make(),
23-
$this->getSaveFormAction()->formId('form'),
28+
$this->getSaveFormAction()->formId('form')
29+
->tooltip(fn (Action $action) => $action->getLabel())
30+
->hiddenLabel()
31+
->icon('tabler-device-floppy'),
2432
];
2533
}
2634

billing/src/Filament/Admin/Resources/Coupons/Pages/ListCoupons.php

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

55
use Boy132\Billing\Filament\Admin\Resources\Coupons\CouponResource;
6-
use Filament\Actions\CreateAction;
76
use Filament\Resources\Pages\ListRecords;
87

98
class ListCoupons extends ListRecords
109
{
1110
protected static string $resource = CouponResource::class;
12-
13-
protected function getHeaderActions(): array
14-
{
15-
return [
16-
CreateAction::make()
17-
->label('Create Coupon'),
18-
];
19-
}
2011
}

billing/src/Filament/Admin/Resources/Customers/CustomerResource.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
use Boy132\Billing\Filament\Admin\Resources\Customers\Pages\EditCustomer;
88
use Boy132\Billing\Filament\Admin\Resources\Customers\Pages\ListCustomers;
99
use Boy132\Billing\Models\Customer;
10+
use Filament\Actions\BulkActionGroup;
11+
use Filament\Actions\CreateAction;
1012
use Filament\Actions\DeleteAction;
13+
use Filament\Actions\DeleteBulkAction;
1114
use Filament\Actions\EditAction;
1215
use Filament\Forms\Components\Select;
1316
use Filament\Forms\Components\TextInput;
@@ -83,6 +86,13 @@ public static function table(Table $table): Table
8386
EditAction::make(),
8487
DeleteAction::make(),
8588
])
89+
->toolbarActions([
90+
CreateAction::make()
91+
->createAnother(false),
92+
BulkActionGroup::make([
93+
DeleteBulkAction::make('exclude_bulk_delete'),
94+
]),
95+
])
8696
->emptyStateHeading('No Customers')
8797
->emptyStateDescription('')
8898
->emptyStateIcon('tabler-user-dollar');

billing/src/Filament/Admin/Resources/Customers/Pages/CreateCustomer.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
namespace Boy132\Billing\Filament\Admin\Resources\Customers\Pages;
44

55
use Boy132\Billing\Filament\Admin\Resources\Customers\CustomerResource;
6+
use Filament\Actions\Action;
67
use Filament\Resources\Pages\CreateRecord;
78

89
class CreateCustomer extends CreateRecord
@@ -19,7 +20,10 @@ protected function getFormActions(): array
1920
protected function getHeaderActions(): array
2021
{
2122
return [
22-
$this->getCreateFormAction()->formId('form'),
23+
$this->getCreateFormAction()->formId('form')
24+
->tooltip(fn (Action $action) => $action->getLabel())
25+
->hiddenLabel()
26+
->icon('tabler-plus'),
2327
];
2428
}
2529
}

billing/src/Filament/Admin/Resources/Customers/Pages/EditCustomer.php

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

55
use Boy132\Billing\Filament\Admin\Resources\Customers\CustomerResource;
66
use Boy132\Billing\Filament\Admin\Resources\Customers\RelationManagers\OrderRelationManager;
7+
use Filament\Actions\Action;
78
use Filament\Actions\DeleteAction;
89
use Filament\Resources\Pages\EditRecord;
910

@@ -19,8 +20,15 @@ protected function getFormActions(): array
1920
protected function getHeaderActions(): array
2021
{
2122
return [
23+
$this->getCancelFormAction()->formId('form')
24+
->tooltip(fn (Action $action) => $action->getLabel())
25+
->hiddenLabel()
26+
->icon('tabler-arrow-left'),
2227
DeleteAction::make(),
23-
$this->getSaveFormAction()->formId('form'),
28+
$this->getSaveFormAction()->formId('form')
29+
->tooltip(fn (Action $action) => $action->getLabel())
30+
->hiddenLabel()
31+
->icon('tabler-device-floppy'),
2432
];
2533
}
2634

billing/src/Filament/Admin/Resources/Customers/Pages/ListCustomers.php

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

55
use Boy132\Billing\Filament\Admin\Resources\Customers\CustomerResource;
6-
use Filament\Actions\CreateAction;
76
use Filament\Resources\Pages\ListRecords;
87

98
class ListCustomers extends ListRecords
109
{
1110
protected static string $resource = CustomerResource::class;
12-
13-
protected function getHeaderActions(): array
14-
{
15-
return [
16-
CreateAction::make()
17-
->label('Create Customer'),
18-
];
19-
}
2011
}

billing/src/Filament/Admin/Resources/Orders/OrderResource.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use Boy132\Billing\Models\ProductPrice;
1414
use Exception;
1515
use Filament\Actions\Action;
16+
use Filament\Actions\CreateAction;
1617
use Filament\Forms\Components\Select;
1718
use Filament\Notifications\Notification;
1819
use Filament\Resources\Resource;
@@ -102,7 +103,9 @@ public static function table(Table $table): Table
102103
->recordActions([
103104
Action::make('activate')
104105
->visible(fn (Order $order) => $order->status !== OrderStatus::Active)
106+
->tooltip('Activate')
105107
->color('success')
108+
->icon('tabler-check')
106109
->requiresConfirmation()
107110
->action(function (Order $order) {
108111
$order->activate(null);
@@ -115,7 +118,9 @@ public static function table(Table $table): Table
115118
}),
116119
Action::make('create_server')
117120
->visible(fn (Order $order) => $order->status === OrderStatus::Active && !$order->server)
121+
->tooltip('Create server')
118122
->color('primary')
123+
->icon('tabler-brand-docker')
119124
->requiresConfirmation()
120125
->action(function (Order $order) {
121126
try {
@@ -131,7 +136,9 @@ public static function table(Table $table): Table
131136
}),
132137
Action::make('close')
133138
->visible(fn (Order $order) => $order->status === OrderStatus::Active)
139+
->tooltip('Close')
134140
->color('danger')
141+
->icon('tabler-x')
135142
->requiresConfirmation()
136143
->action(function (Order $order) {
137144
$order->close();
@@ -143,6 +150,10 @@ public static function table(Table $table): Table
143150
->send();
144151
}),
145152
])
153+
->toolbarActions([
154+
CreateAction::make()
155+
->createAnother(false),
156+
])
146157
->emptyStateHeading('No Orders')
147158
->emptyStateDescription('')
148159
->emptyStateIcon('tabler-truck-delivery');

billing/src/Filament/Admin/Resources/Orders/Pages/ListOrders.php

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Boy132\Billing\Enums\OrderStatus;
66
use Boy132\Billing\Filament\Admin\Resources\Orders\OrderResource;
77
use Boy132\Billing\Models\Order;
8-
use Filament\Actions\CreateAction;
98
use Filament\Resources\Pages\ListRecords;
109
use Filament\Schemas\Components\Tabs\Tab;
1110
use Illuminate\Database\Eloquent\Builder;
@@ -14,15 +13,6 @@ class ListOrders extends ListRecords
1413
{
1514
protected static string $resource = OrderResource::class;
1615

17-
protected function getHeaderActions(): array
18-
{
19-
return [
20-
CreateAction::make()
21-
->label('Create Order')
22-
->createAnother(false),
23-
];
24-
}
25-
2616
public function getDefaultActiveTab(): string
2717
{
2818
return OrderStatus::Active->value;

0 commit comments

Comments
 (0)