Skip to content

[6.x] Asset container actions - #15461

Merged
jasonvarga merged 4 commits into
statamic:6.xfrom
jacksleight:feature/container-actions
Sep 17, 2026
Merged

jasonvarga merged 4 commits into
statamic:6.xfrom
jacksleight:feature/container-actions

Conversation

@jacksleight

@jacksleight jacksleight commented Sep 16, 2026

Copy link
Copy Markdown
Contributor

This PR adds actions for asset containers, mirroring #10471 and #13137.

<?php

namespace App\Actions;

use Statamic\Actions\Action;
use Statamic\Contracts\Assets\AssetContainer;

class UploadArchive extends Action
{
    public function visibleTo($item)
    {
        return $item instanceof AssetContainer;
    }

    public function run($items, $values)
    {
        $container = $items->first();

        // ...
    }
}

Notes:

  • Collections put actions and actionUrl on the page as top level props. Containers go inside the existing container object as actions and actions_url, because Browser.vue only receives container.
  • Browser.vue is shared with the asset fieldtype's selector, which overrides the #header slot, so container actions never show up inside a fieldtype.
  • On completion, collections do a full router.reload(). Containers refresh the listing in place instead.
  • Called it ContainerActionController rather than AssetContainerActionController to match FolderActionController.
  • collections/Show.vue has an afterActionSuccessfullyCompleted method that nothing calls. The ItemActions there binds no @completed and the page doesn't use the HasActions mixin, so collection actions didnt fire toasts. That's also wired up now.

@duncanmcclean

Copy link
Copy Markdown
Member

Nice! 🔥

Out of curiosity, what's your use case for asset container actions?

@jacksleight

jacksleight commented Sep 16, 2026

Copy link
Copy Markdown
Contributor Author

I have a project where the client needs to upload results exports from running event time tracking systems. They're ZIP files that contain HTML/CSS/JS files as well as CSVs and PDFs. The files all link to each other and would get sanitised or could get disorganised if uploaded individually. There are also two different systems with different file structures.

So to ensure everything always lands in the right place and is structured correctly I've built an action that lets them upload the ZIP directly, along with the event title/date, then the action creates the right folder structure and extracts the files (it also does its own checks to make sure there is nothing suspect in the ZIP).

Refreshing only the listing left the container's own data (e.g. title) stale until a manual reload, unlike the equivalent collection-action flow which does a full reload.
@jasonvarga
jasonvarga merged commit 942e8e9 into statamic:6.x Sep 17, 2026
61 checks passed
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.

3 participants