44
55use Closure ;
66use Filament \Actions \Action as FilamentActionsAction ;
7- use Filament \Actions \ActionGroup as FilamentActionsActionGroup ;
87use Filament \Actions \Exceptions \ActionNotResolvableException ;
98use Filament \Schemas \Schema ;
109use Illuminate \Database \Eloquent \Model ;
1514trait HasActions
1615{
1716 protected array $ cachedTreeToolbarActions = [];
17+
1818 protected array $ cachedTreeActions = [];
1919
2020 protected function resolveAction (array $ action , array $ parentActions ): ?FilamentActionsAction
@@ -42,10 +42,10 @@ protected function resolveAction(array $action, array $parentActions): ?Filament
4242
4343 if (filled ($ action ['context ' ]['recordKey ' ] ?? null )) {
4444 $ record = $ this ->getTreeRecord ($ action ['context ' ]['recordKey ' ]);
45-
45+
4646 $ resolvedAction ->getRootGroup ()?->record($ record ) ?? $ resolvedAction ->record ($ record );
4747 }
48-
48+
4949 return $ resolvedAction ;
5050 }
5151 }
@@ -71,14 +71,14 @@ public function cacheTreeActions(): void
7171 // Set tree on action
7272 if (method_exists ($ action , 'tree ' )) {
7373 $ action = $ action ->tree ($ this ->getCachedTree ());
74- }
74+ }
7575 // Set livewire on action
7676 else {
7777 $ action = $ action ->livewire ($ this );
7878 }
7979
8080 return $ action ;
81- };
81+ };
8282
8383 return collect ($ actions )
8484 ->whereInstanceOf ([
@@ -90,17 +90,17 @@ public function cacheTreeActions(): void
9090 if ($ action instanceof ActionGroup) {
9191 return $ action ->getFlatActions ();
9292 }
93+
9394 return [$ action ];
94- })
95+ })
9596 // Configure action
96- ->map (fn (Action |FilamentActionsAction $ action ) =>
97- $ action ->configureUsing (
98- Closure::fromCallable ([$ this , 'configureTreeAction ' ]),
99- fn () => $ action ->configure (),
100- )
97+ ->map (fn (Action |FilamentActionsAction $ action ) => $ action ->configureUsing (
98+ Closure::fromCallable ([$ this , 'configureTreeAction ' ]),
99+ fn () => $ action ->configure (),
100+ )
101101 )
102102 // Key by action name (resolve used)
103- ->mapWithKeys (fn (Action | FilamentActionsAction $ action ) => [
103+ ->mapWithKeys (fn (Action | FilamentActionsAction $ action ) => [
104104 $ action ->getName () => $ configureResolvedAction ($ action ),
105105 ])
106106 ->all ();
0 commit comments