Skip to content

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

Open
Devsome wants to merge 3 commits intostatamic:6.xfrom
Devsome:6.x
Open

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

Conversation

@Devsome
Copy link

@Devsome Devsome commented Mar 24, 2026

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

<?php

namespace App\Actions;

use Illuminate\Support\Facades\Log;
use Statamic\Actions\Action;

class CustomActionInTreeView extends Action
{
    protected $icon = 'add-item';
    protected $confirm = false;

    /**
     * The run method
     *
     * @return mixed
     */
    public function run($items, $values)
    {
        Log::info('Custom Action in Tree View executed', [
            'items' => $items,
            'values' => $values,
        ]);
    }

    public static function title(): string
    {
        return 'Custom Action in Tree View';
    }

    public function visibleTo($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

@Devsome Devsome changed the title Make actions available in a collection tree view [6.x] Make actions available in a collection tree view Mar 24, 2026
Sign up for free to 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.

1 participant