dcasia / icon-action-toolbar

Replaces the default boring action menu with an inline row of icon-based actions.
MIT License
20 stars 6 forks source link

Problem adding the icon #12

Closed nikoo-eshratabadi closed 2 months ago

nikoo-eshratabadi commented 3 months ago

Laravel Version: 10.10 Nova Version: 4.25.1 PHP Version: 8.1.23

i'm having trouble adding icon to my actions with this error. " Method 'icon' not found in Actions\CustomImpersonation " Although i have required this package, i can't add an icon

public function actions(NovaRequest $request)
{
    return [
        CustomImpersonation::make()->showInline()->icon('')
    ];
}
milewski commented 3 months ago

See here: https://github.com/dcasia/icon-action-toolbar/blob/2929c90d153553c0bc1d6072d8bdca4399848f23/src/IconActionToolbarServiceProvider.php#L16C9-L16C15

This package creates a macro on the Action class. If your CustomImpersonation class doesn't extend the default Nova Action class, you can work around this by defining the same macro for it.

nikoo-eshratabadi commented 3 months ago

i actually do extend the default nova action class . It looks something like this.


use Laravel\Nova\Actions\Action;

class CustomImpersonation extends Action
{
    use InteractsWithQueue, Queueable, showAsButton;
    public function handle(ActionFields $fields, Collection $models)
    {
        return true;
    }
}
nikoo-eshratabadi commented 3 months ago

update : i'm using https://packagist.org/packages/lednerb/nova-action-button-selectors in my action. maybe this is preventing the icon from appearing but when i delete the 'showAsButton' trait from my action, the icon still doesn't work. and it's only visible in the drop down menu ... like this

588DAC55-A00F-46A4-B6AF-63C524FB747F_1_201_a


use Lednerb\ActionButtonSelector\ShowAsButton;

class CustomImpersonation extends Action
{
    use InteractsWithQueue, Queueable, showAsButt
}

and i register it like this

```    public function actions(NovaRequest $request)
    {
        return [
            CustomImpersonation::make()->showInline()->icon('finger-print')
        ];
    }