You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
1.Define a ```getContextMenu```method inside the page (resource page or custom page), the method should return an instance of ```AymanAlhattami\FilamentContextMenu\ContextMenu```
27
-
2.Use ```ContextMenu```class to set menu actions as an array
26
+
1.Add the trait ```AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions```to the page you want to add context menu.
27
+
2.Then, define a ```getContextMenuActions```method inside the page, the method should return an array of [Filament Actions](https://filamentphp.com/docs/3.x/actions/installation)
28
28
29
29
```php
30
30
use App\Filament\Resources\UserResource\Pages\CreateUser;
31
31
use Filament\Resources\Pages\ListRecords;
32
32
use AymanAlhattami\FilamentContextMenu\ContextMenu;
33
33
use Filament\Actions\Action;
34
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
34
35
35
36
class ListUsers extends ListRecords
36
37
{
37
-
//
38
+
use InteractsWithContextMenuActions;
38
39
39
-
public static function getContextMenu(): ContextMenu
40
+
public function getContextMenuActions(): array
40
41
{
41
-
return ContextMenu::make()
42
-
->actions([
43
-
Action::make('Create user')
44
-
->url(CreateUser::getUrl())
45
-
]);
42
+
return [
43
+
Action::make('Create user')
44
+
->url(CreateUser::getUrl())
45
+
];
46
46
}
47
47
48
48
//
@@ -57,24 +57,25 @@ Use ```AymanAlhattami\FilamentContextMenu\ContextMenuDivider``` to set divider b
57
57
use App\Filament\Resources\UserResource\Pages\CreateUser;
58
58
use App\Filament\Resources\UserResource\Pages\TrashedUsers;
59
59
use Filament\Resources\Pages\ListRecords;
60
-
use AymanAlhattami\FilamentContextMenu\ContextMenu;
61
60
use Filament\Actions\Action;
62
61
use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;
62
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
63
63
64
64
class ListUsers extends ListRecords
65
65
{
66
+
use InteractsWithContextMenuActions;
67
+
66
68
//
67
69
68
-
public static function getContextMenu(): ContextMenu
70
+
public static function getContextMenuActions(): array
69
71
{
70
-
return ContextMenu::make()
71
-
->actions([
72
-
Action::make('Create user')
73
-
->url(CreateUser::getUrl()),
74
-
ContextMenuDivider::make(),
75
-
Action::make('Trashed user')
76
-
->url(TrashedUsers::getUrl()),
77
-
]);
72
+
return [
73
+
Action::make('Create user')
74
+
->url(CreateUser::getUrl()),
75
+
ContextMenuDivider::make(),
76
+
Action::make('Trashed user')
77
+
->url(TrashedUsers::getUrl()),
78
+
];
78
79
}
79
80
80
81
//
@@ -86,18 +87,20 @@ You can use ```Filament\Actions\CreateAction```
86
87
87
88
```php
88
89
use Filament\Resources\Pages\ListRecords;
89
-
use AymanAlhattami\FilamentContextMenu\ContextMenu;
90
+
use AymanAlhattami\FilamentContextMenu\ContextMenuDivider;
91
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
90
92
91
93
class ListUsers extends ListRecords
92
94
{
95
+
use InteractsWithContextMenuActions;
96
+
93
97
//
94
98
95
-
public static function getContextMenu(): ContextMenu
99
+
public static function getContextMenuActions(): array
96
100
{
97
-
return ContextMenu::make()
98
-
->actions([
99
-
\Filament\Actions\CreateAction::make()
100
-
]);
101
+
return [
102
+
\Filament\Actions\CreateAction::make()
103
+
];
101
104
}
102
105
103
106
//
@@ -108,19 +111,21 @@ class ListUsers extends ListRecords
108
111
You can use ```Filament\Actions\EditAction```
109
112
110
113
```php
111
-
use Filament\Resources\Pages\ListRecords;
114
+
use Filament\Resources\Pages\ViewRecord;
112
115
use AymanAlhattami\FilamentContextMenu\ContextMenu;
116
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
113
117
114
-
class ListUsers extends ListRecords
118
+
class ViewUser extends ViewRecord
115
119
{
120
+
use InteractsWithContextMenuActions;
121
+
116
122
//
117
123
118
-
public static function getContextMenu(): ContextMenu
124
+
public static function getContextMenuActions(): array
119
125
{
120
-
return ContextMenu::make()
121
-
->actions([
122
-
\Filament\Actions\EditAction::make()
123
-
]);
126
+
return [
127
+
\Filament\Actions\EditAction::make()
128
+
];
124
129
}
125
130
126
131
//
@@ -131,19 +136,21 @@ class ListUsers extends ListRecords
131
136
You can use ```Filament\Actions\ViewAction```
132
137
133
138
```php
134
-
use Filament\Resources\Pages\ListRecords;
139
+
use Filament\Resources\Pages\EditRecord;
135
140
use AymanAlhattami\FilamentContextMenu\ContextMenu;
141
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
136
142
137
-
class ListUsers extends ListRecords
143
+
class EditUser extends EditRecord
138
144
{
145
+
use InteractsWithContextMenuActions;
146
+
139
147
//
140
148
141
-
public static function getContextMenu(): ContextMenu
149
+
public static function getContextMenuActions(): array
142
150
{
143
-
return ContextMenu::make()
144
-
->actions([
145
-
\Filament\Actions\ViewAction::make()
146
-
]);
151
+
return [
152
+
\Filament\Actions\ViewAction::make()
153
+
];
147
154
}
148
155
149
156
//
@@ -154,19 +161,21 @@ class ListUsers extends ListRecords
154
161
You can use ```Filament\Actions\DeleteAction```
155
162
156
163
```php
157
-
use Filament\Resources\Pages\ListRecords;
164
+
use Filament\Resources\Pages\ViewRecord;
158
165
use AymanAlhattami\FilamentContextMenu\ContextMenu;
166
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
159
167
160
-
class ListUsers extends ListRecords
168
+
class ViewUser extends ViewRecord
161
169
{
170
+
use InteractsWithContextMenuActions;
171
+
162
172
//
163
173
164
-
public static function getContextMenu(): ContextMenu
174
+
public static function getContextMenuActions(): array
165
175
{
166
-
return ContextMenu::make()
167
-
->actions([
168
-
\Filament\Actions\DeleteAction::make()
169
-
]);
176
+
return [
177
+
\Filament\Actions\DeleteAction::make()
178
+
];
170
179
}
171
180
172
181
//
@@ -179,17 +188,19 @@ You can use ```Filament\Actions\ExportAction```
179
188
```php
180
189
use Filament\Resources\Pages\ListRecords;
181
190
use AymanAlhattami\FilamentContextMenu\ContextMenu;
191
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
182
192
183
193
class ListUsers extends ListRecords
184
194
{
195
+
use InteractsWithContextMenuActions;
196
+
185
197
//
186
198
187
-
public static function getContextMenu(): ContextMenu
199
+
public static function getContextMenuActions(): array
188
200
{
189
-
return ContextMenu::make()
190
-
->actions([
191
-
\Filament\Actions\ExportAction::make()
192
-
]);
201
+
return [
202
+
\Filament\Actions\ExportAction::make()
203
+
];
193
204
}
194
205
195
206
//
@@ -200,19 +211,21 @@ class ListUsers extends ListRecords
200
211
You can use ```Filament\Actions\ForceDeleteAction```
201
212
202
213
```php
203
-
use Filament\Resources\Pages\ListRecords;
214
+
use Filament\Resources\Pages\ViewRecord;
204
215
use AymanAlhattami\FilamentContextMenu\ContextMenu;
216
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
205
217
206
-
class ListUsers extends ListRecords
218
+
class ViewUser extends ViewRecord
207
219
{
220
+
use InteractsWithContextMenuActions;
221
+
208
222
//
209
223
210
-
public static function getContextMenu(): ContextMenu
224
+
public static function getContextMenuActions(): array
211
225
{
212
-
return ContextMenu::make()
213
-
->actions([
214
-
\Filament\Actions\ForceDeleteAction::make()
215
-
]);
226
+
return [
227
+
\Filament\Actions\ForceDeleteAction::make()
228
+
];
216
229
}
217
230
218
231
//
@@ -225,17 +238,19 @@ You can use ```Filament\Actions\ImportAction```
225
238
```php
226
239
use Filament\Resources\Pages\ListRecords;
227
240
use AymanAlhattami\FilamentContextMenu\ContextMenu;
241
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
228
242
229
243
class ListUsers extends ListRecords
230
244
{
245
+
use InteractsWithContextMenuActions;
246
+
231
247
//
232
248
233
-
public static function getContextMenu(): ContextMenu
249
+
public static function getContextMenuActions(): array
234
250
{
235
-
return ContextMenu::make()
236
-
->actions([
237
-
\Filament\Actions\ImportAction::make()
238
-
]);
251
+
return [
252
+
\Filament\Actions\ImportAction::make()
253
+
];
239
254
}
240
255
241
256
//
@@ -248,17 +263,19 @@ You can use ```Filament\Actions\ReplicateAction```
248
263
```php
249
264
use Filament\Resources\Pages\ListRecords;
250
265
use AymanAlhattami\FilamentContextMenu\ContextMenu;
266
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
251
267
252
-
class ListUsers extends ListRecords
268
+
class ViewUser extends ViewRecord
253
269
{
270
+
use InteractsWithContextMenuActions;
271
+
254
272
//
255
273
256
-
public static function getContextMenu(): ContextMenu
274
+
public static function getContextMenuActions(): array
257
275
{
258
-
return ContextMenu::make()
259
-
->actions([
260
-
\Filament\Actions\ReplicateAction::make()
261
-
]);
276
+
return [
277
+
\Filament\Actions\ReplicateAction::make()
278
+
];
262
279
}
263
280
264
281
//
@@ -271,35 +288,36 @@ You can use ```Filament\Actions\RestoreAction```
271
288
```php
272
289
use Filament\Resources\Pages\ListRecords;
273
290
use AymanAlhattami\FilamentContextMenu\ContextMenu;
291
+
use AymanAlhattami\FilamentContextMenu\InteractsWithContextMenuActions;
274
292
275
293
class ListUsers extends ListRecords
276
294
{
295
+
use InteractsWithContextMenuActions;
296
+
277
297
//
278
298
279
-
public static function getContextMenu(): ContextMenu
299
+
public static function getContextMenuActions(): array
280
300
{
281
-
return ContextMenu::make()
282
-
->actions([
283
-
\Filament\Actions\RestoreAction::make()
284
-
]);
301
+
return [
302
+
\Filament\Actions\RestoreAction::make()
303
+
];
285
304
}
286
305
287
306
//
288
307
}
289
308
```
290
309
291
310
### Note
292
-
For action to have a nice look, use ```->link()``` method for the action
311
+
For action to have a nice style, use ```->link()``` method a the action, [link](https://filamentphp.com/docs/3.x/actions/trigger-button#choosing-a-trigger-style)
293
312
294
313
```php
295
-
public static function getContextMenu(): ContextMenu
314
+
public static function getContextMenuActions(): array
0 commit comments