Files
nova-row-actions/README.md
T
2026-07-30 13:44:55 +03:30

110 lines
3.5 KiB
Markdown

# Nova Row Actions
displays ordinary Laravel Nova actions as
visible, accessible buttons in resource index rows. It uses Nova's standard
action endpoint, authorization, confirmation forms, response handling, and
table refresh flow.
## Requirements
- PHP 8.1+
- Laravel 10.48+, 11.44+, 12.1+, or 13
- Laravel Nova 5.8.3+
## Installation
Install the package with Composer. Laravel package discovery registers its
service provider and compiled Nova assets automatically.
```bash
composer require meghdadfadaee/nova-row-actions
```
## Usage
Add the field to a Nova resource and keep each represented action registered
in the resource's `actions()` method. The latter is required because Nova's
standard action endpoint only executes actions registered by the resource.
```php
use Illuminate\Database\Eloquent\Model;
use MeghdadFadaee\NovaRowActions\RowActions;
public function fields(NovaRequest $request): array
{
return [
RowActions::make('Actions')
->add(
Approve::make(),
icon: 'check',
color: 'success',
activeWhen: fn (Model $model) => $model->approved,
disabledWhen: fn (Model $model) => $model->approved,
confirm: false,
)
->add(
Reject::make(),
icon: 'x-mark',
color: 'danger',
tooltip: 'Reject this record',
visibleWhen: fn (Model $model) => ! $model->archived,
order: 20,
confirm: true,
),
];
}
public function actions(NovaRequest $request): array
{
return [
Approve::make()->exceptInline(),
Reject::make()->exceptInline(),
];
}
```
`exceptInline()` leaves actions available in Nova's bulk selector and detail
view while removing them from the row ellipsis.
## Button options
`add()` accepts the following named arguments:
- `icon`: a Nova icon name, such as `check` or `x-mark`.
- `color`: `default`, `primary`, `success`, `danger`, `warning`, or `info`.
- `variant`: `outline`, `solid`, or `ghost`.
- `label`: button/accessibility label; defaults to the action name.
- `tooltip`: tooltip text; defaults to the resolved label.
- `activeWhen`: boolean or row callback controlling the pressed/active state.
- `disabledWhen`: boolean or row callback controlling disabled state.
- `visibleWhen`: boolean or row callback controlling server-side visibility.
- `order`: numeric order; insertion order is used by default.
- `confirm`: `true` to force confirmation, `false` to skip it, or `null` to
preserve the Nova action's own confirmation strategy.
- `showLabel`: display text beside the icon; labels remain available to screen
readers when this is false.
Callbacks receive `(Model $model, NovaRequest $request, Action $action)` and may
declare only the leading arguments they need.
## Notes and limitations
- Actions must be normal resource actions registered by `actions()`. Pivot-only
actions and lens-specific endpoints are not supported by the field.
- Relationship indexes are supported through Nova's `viaResource`,
`viaResourceId`, and `viaRelationship` action parameters.
- Nova action fields, validation errors, downloads, events, response modals,
redirects, visits, danger messages, notifications, and progress state are
delegated to Nova 5.8.3's native action composable.
- The package ships compiled production assets; Node is only needed when
modifying the Vue or CSS sources.
## Development
```bash
npm ci
npm test
npm run production
composer validate --strict
```