Menu
Introduction
Getting Started
Developer guide
Release
Architecture
CLI
Technical documentations
Version
Publication date

Mar 9, 2022

Confidentiality
Public
Reactions
1
Share

EntityActionPlugin

Base class for a brick-contributed entity action provider.

Subclass it, set :attr:entity_action_type, implement :meth:get_actions and :meth:execute_action, then decorate the subclass with @entity_action_plugin. The subclass is instantiated once and registered in the global :class:EntityActionRegistry.

Because a disabled brick's modules are never imported, its plugins are never registered: the conditional appearance of actions comes for free.

Attributes
entity_action_type: EntityActionType
Functions
execute_action

Run the action identified by action_name.

action_name is the short, un-namespaced name (the dispatch endpoint strips the plugin namespace before calling this). May return a navigation instruction in the result.

entity : Model
action_name : str
Return type : EntityActionResultDTO
get_actions

Return the actions to show for the given entity.

entity is a model instance of :attr:entity_action_type. Return an empty list when no action applies.

IMPORTANT: this is called for every plugin of the entity type on every GET /entity-action/{entity_type}/{id} request. It MUST be cheap - only in-memory checks on the already-loaded entity (type, flags, file extension). Do not load resource content, query the DB, or do I/O.

entity : Model
Return type : list
Shine Logo
Technical bricks to reuse or customize

Have you developed a brick?

Share it to accelerate projects for the entire community.