Skip to content

Add ResourceActionRegistry for package-contributed Resource actions - #87

Open
Ivanh00 wants to merge 1 commit into
mainfrom
feature/resource-action-registry
Open

Add ResourceActionRegistry for package-contributed Resource actions#87
Ivanh00 wants to merge 1 commit into
mainfrom
feature/resource-action-registry

Conversation

@Ivanh00

@Ivanh00 Ivanh00 commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

Motivation

Commercial plugins (developed alongside Aura Reports) need to contribute Resource actions without mutating host Resource classes or shipping view overrides. Today, actions only come from Resource::getActions(), so every plugin-added action requires touching core Resources.

What this adds

  • Aura\Base\Contracts\ResourceActionRegistry — a small contract: register(), actionsFor($resource, $actor), execute($name, $resource, $actor), plus the boot/worker state hooks used by the other Aura singletons.
  • Aura\Base\Services\ResourceActionRegistry — the singleton implementation. Plugins register namespaced action definitions (e.g. aura-reports.duplicate); duplicate names fail deterministically with ResourceActionConflict.
  • HasActions integrationgetActionsProperty() merges contributed actions with Resource-owned ones (Resource-owned actions keep precedence on name collisions), and singleAction() executes contributed actions through the registry. Contributed actions run a fresh server-side authorization check before execution; authorization failures abort with 403.
  • State lifecycle — registrations made during package boot are captured as a baseline (captureBaselineState()), and Aura::flushState() / worker boundaries restore it, mirroring TeamScope/ScopedScope handling. The provider binds the singleton and captures the baseline in the existing booted hook.
  • View fix — the actions blade no longer hides all actions behind the legacy ownership check; visibility is now computed in HasActions where contributed actions are also filtered for the actor.

Security properties

  • Contributed actions are re-authorized server-side at execution time; nothing relies on the rendered dropdown alone.
  • conditional_logic on contributed definitions is evaluated like Resource-owned ones.
  • Resource-owned actions always win name collisions, so a plugin cannot shadow a Resource's own action.
  • Registration happens through the container-bound contract only; nothing is user/input-driven.

Tests

tests/Feature/Resource/ResourceActionRegistryTest.php covers: contributed actions rendering for permitted actors, precedence on collisions, deterministic conflict failures, worker flush restoring the boot baseline, and execution authorization. Full local suite: 1825 passed, 4 skipped (browser tests run in CI; Playwright not installed locally).

Developed while building the Aura Reports plugin — that plugin will consume this seam instead of overriding views.

Plugins can register namespaced Resource actions through a singleton
registry (Aura\Base\Contracts\ResourceActionRegistry) instead of
mutating Resource classes. Resource-owned actions keep precedence on
name collisions, contributed actions re-authorize server-side before
execution, registrations are captured at boot and restored at worker
boundaries like the other Aura state singletons, and the actions view
no longer hides contributed actions behind the legacy ownership check.
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