Skip to content

[6.x] Make actions available in a collection tree view - #14331

Open
Devsome wants to merge 35 commits into
statamic:6.xfrom
Devsome:6.x
Open

[6.x] Make actions available in a collection tree view#14331
Devsome wants to merge 35 commits into
statamic:6.xfrom
Devsome:6.x

Conversation

@Devsome

Copy link
Copy Markdown

Hello everyone,

First of all, thank you for Statamic 6. After someone on Discord pointed me to Issue 575 and I saw the other pull requests 4070 & 4439, I decided to give it a try and follow the contribution guidelines.

Procedure:

  • Created a new blank project
  • Forked Statamic 6 and linked it locally in composer.json
  • Ran npm ci && npm run build in the statamic/cms project
  • Ran ddev artisan vendor:publish --tag=statamic-cp --force && ddev yarn build && ddev artisan optimize:clear
  • Created a custom action ddev artisan statamic:make:action

If I've forgotten anything or something is missing, please let me know. Even if it isn't accepted, as stated in the Contribution Guidelines, it might still be helpful to others who need it.

This is what my custom action looks like

<?phpnamespaceApp\Actions;
useIlluminate\Support\Facades\Log;
useStatamic\Actions\Action;
class CustomActionInTreeView extends Action
{
protected$icon = 'add-item';
protected$confirm = false;
/** * The run method * * @return mixed */publicfunctionrun($items, $values)
{
Log::info('Custom Action in Tree View executed', [
'items' => $items,
'values' => $values,
]);
}
publicstaticfunctiontitle(): string
{
return'Custom Action in Tree View';
}
publicfunctionvisibleTo($item): bool
{
$view = $this->context['view'] ?? 'list';
return$view === 'tree';
}
}

How it looks like in the TreeView:
image

How it looks like in the ListView:
image

@DevsomeDevsome changed the title Make actions available in a collection tree view[6.x] Make actions available in a collection tree viewMar 24, 2026

@jasonvargajasonvarga left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is looking good, thanks!

However we are moving away from sending all the actions down the wire initially. It really bloats the responses.

We have a mechanism to lazily load the actions when you hover over the dropdown. You should rework this PR to allow for that.

See RowActions.vue which is used in the Listing component.

https://github.com/statamic/cms/blob/6.x/resources/js/components/ui/Listing/RowActions.vue

In fact you might actually be able to use the RowActions component itself.

…e component is mounted. Update the Show page to display the skeleton loader. Remove unnecessary action references in TreeBuilder.
@Devsome

Copy link
Copy Markdown
Author

Hello @jasonvarga thanks for your response,
I've made some adjustments based on what I understood from you.
My „CustomActionInTreeView“ which I mentioned in my first comment, still works as intended.

Feel free to let me know what you think.
Best regards

@Devsome
Devsome requested a review from jasonvargaApril 7, 2026 08:06
@Devsome

Copy link
Copy Markdown
Author

@jasonvarga I also fixed the issue where the modal remained open after clicking an action, and based on what I saw in RowActions.vue, I’ve now set the „default“ value for :variants in Show.vue instead of undefined.

@Devsome
Devsome marked this pull request as draft April 15, 2026 08:03
@Devsome
Devsome marked this pull request as ready for review April 15, 2026 12:45
@Devsome

Copy link
Copy Markdown
Author

I've made a few more adjustments to ensure it runs smoothly. Please give it a try and let me know what you think.

@Devsome

Copy link
Copy Markdown
Author

@jasonvarga Is there anything I can do to help here, or are you guys just too busy with other, more important PR right now? Cheers

@edalzell

Copy link
Copy Markdown
Contributor

They get to it when they get to it, there's a long list of PRs already!

@Devsome

Copy link
Copy Markdown
Author

dunno what happend, but the PHPStan / Analyze (pull_request) test is failing.

@duncanmcclean

Copy link
Copy Markdown
Member

Don't worry about it - #15083 should fix it.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

@Devsome@edalzell@duncanmcclean@jasonvarga