{"id":21972974,"url":"https://github.com/pavloniym/nova-action-buttons","last_synced_at":"2025-04-09T13:07:38.684Z","repository":{"id":64155213,"uuid":"573771818","full_name":"pavloniym/nova-action-buttons","owner":"pavloniym","description":"This package allows you to execute an action directly on your resource table view.","archived":false,"fork":false,"pushed_at":"2024-11-01T21:16:27.000Z","size":662,"stargazers_count":14,"open_issues_count":14,"forks_count":11,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-02T10:48:03.154Z","etag":null,"topics":["actions","buttons","laravel","nova"],"latest_commit_sha":null,"homepage":"https://novapackages.com/packages/pavloniym/nova-action-buttons","language":"Vue","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pavloniym.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-12-03T11:37:57.000Z","updated_at":"2024-12-17T23:34:03.000Z","dependencies_parsed_at":"2024-11-15T22:30:20.681Z","dependency_job_id":"047e50da-aa95-4aee-8bb4-db8ecef6055a","html_url":"https://github.com/pavloniym/nova-action-buttons","commit_stats":{"total_commits":17,"total_committers":3,"mean_commits":5.666666666666667,"dds":0.4117647058823529,"last_synced_commit":"d3313d32cf5e19de432e3d6d869f6c7dedb9a2c9"},"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavloniym%2Fnova-action-buttons","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavloniym%2Fnova-action-buttons/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavloniym%2Fnova-action-buttons/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pavloniym%2Fnova-action-buttons/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pavloniym","download_url":"https://codeload.github.com/pavloniym/nova-action-buttons/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045231,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["actions","buttons","laravel","nova"],"created_at":"2024-11-29T15:23:44.191Z","updated_at":"2025-04-09T13:07:38.664Z","avatar_url":"https://github.com/pavloniym.png","language":"Vue","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nova Action Buttons\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/pavloniym/nova-action-buttons?style=flat-square)](https://packagist.org/packages/pavloniym/nova-action-buttons)\n![Licence](https://img.shields.io/github/license/pavloniym/nova-action-buttons?style=flat-square)\n[![Total Downloads](https://poser.pugx.org/pavloniym/nova-action-buttons/downloads?format=flat-square)](https://packagist.org/packages/pavloniym/nova-action-buttons)\n\nThis [Laravel Nova](https://nova.laravel.com) package allows you to execute an action directly on your resource table\nview.\n\n\n## Requirements\n\n- `php: \u003e=8.0`\n- `laravel/nova: ^4.1`\n\n## Installation\n\nInstall the package in a Laravel Nova project via Composer:\n\n```bash\ncomposer require pavloniym/nova-action-buttons\n```\n\n## Usage\n\n### Single button\n![Nova Action Buttons](https://raw.githubusercontent.com/pavloniym/nova-action-buttons/main/.github/assets/screenshot1.png)  \nYou can add single button to execute action from index row\n\n```php\nuse Pavloniym\\ActionButtons\\ActionButton;\n\npublic function fields(Request $request)\n{\n    return [\n      \n        // ... Nova default fields\n      \n        ActionButton::make('') // Name in resource table column\n            -\u003eicon('lightning-bolt') // heroicon name  -\u003eicon('lightning-bolt')\n            -\u003eiconHtml('\u003csvg\u003e\u003c/svg\u003e') // Svg (or html) icon\n            -\u003eiconUrl('https://img.com/icon.png') // Url of icon\n            -\u003etext('Refresh') // Title (optional)\n            -\u003etooltip('Magic tooltip here') // Tooltip text (optional). If not provided, it will default to the action name.\n            -\u003estyles([]) // Custom css styles (optional)\n            -\u003eclasses([]) // Custom css classes (optional)\n            -\u003eaction(new RefreshAction, $this-\u003eresource-\u003eid) // Provide action instance and resource id\n            -\u003easToolbarButton(), // Display as row toolbar button (optional)\n      \n        // ... Nova default fields\n    ];\n}\n```\n\n### Collection of buttons\n![Nova Action Buttons](https://raw.githubusercontent.com/pavloniym/nova-action-buttons/main/.github/assets/screenshot2.png)  \nYou can add collection of buttons to index row\n\n\n```php\nuse Pavloniym\\ActionButtons\\ActionButton;\n\npublic function fields(Request $request)\n{\n    return [\n      \n        // ... Nova default fields\n      \n        ActionButtons::make()-\u003ecollection([\n            ActionButton::make('')-\u003eaction(),\n            ActionButton::make('')-\u003eaction(),\n            ActionButton::make('')-\u003eaction(),\n        ])\n      \n        // ... Nova default fields\n    ];\n}\n```\n\n\n\u003e This fields (both `ActionButton` and `ActionButtons`) are available on index and detail (Thanks to [@CosminBd](https://github.com/CosminBd)) views\n\n\n## Caveats\n* Currently, in order to use this field, you still have to declare the action in your resource `actions()` method.\n* Tested only on `confirm-action-modal` action\n* You should provide action instance in `action()` method of button.\n* If you have action fields that are depends on resource instance -\u003e you should inject resource in action constructor, because Nova doesn't provide `NovaRequest` instance to `fields` method on index row\n\n```php\nclass RefreshAction extends Action \n{\n\n    private Torrent $torrent\n\n    /**\n     * @param Torrent $torrent\n     */\n    public function __construct(Torrent $torrent)\n    {\n        $this-\u003etorrent = $torrent;\n    }\n\n\n    \n    /**\n     * Get the fields available on the action.\n     *\n     * @param NovaRequest $request\n     * @return array|null\n     */\n    public function fields(NovaRequest $request): ?array\n    {\n   \n        // $request is empty if action is called from index row (or inline)\n        // so use instance injected to action constructor\n        $torrent = (fn(): ?Torrent =\u003e $request?-\u003eselectedResources()?-\u003efirst())();\n        $torrent = $torrent ?? $this-\u003etorrent;\n\n        if ($torrent) {\n            return [\n                File::make('File')-\u003ecreationRules(['required'])\n            ];\n        }\n\n        return null;\n    }\n\n}\n\n```\n\n---\nTo hide the action either on Index or Detail, you can add the methods in the action declaration as per:\n```php\nActionButton::make('My action')\n    -\u003eaction((new RefreshAction)-\u003eonlyOnDetail(), $this-\u003eresource?-\u003eid)\n    -\u003eicon('')\n    -\u003easToolbarButton(),\n```\nThis is available for both action buttons and action button groups, and it works in individual actions which are part of the action group.\n\n---\n\nTo run actions without confirmation, you can add the `$withoutConfirmation = true` property to the Laravel Nova action or provide it as a method when you declare the action button\n```php\nActionButton::make('My action')\n    -\u003eaction((new RefreshAction)-\u003ewithoutConfirmation(), $this-\u003eresource?-\u003eid)\n    -\u003eicon('')\n    -\u003easToolbarButton(),\n```\n\n\n## License\n\nThis project is open-sourced software licensed under the [MIT license](LICENSE.md).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavloniym%2Fnova-action-buttons","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpavloniym%2Fnova-action-buttons","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpavloniym%2Fnova-action-buttons/lists"}