Entity Actions

Entity Actions give developers the ability to add custom actions to a fly-out menu.

Entity Actions was previously known as Tree Actions.

Entity Actions is an extension type providing a fly-out context menu for secondary or additional functionality to an entity (like documents or media).

Developers can define and associate custom actions for entities in a tree extension, workspace, or collection view. Access to these actions can be controlled via user permissions. The Users section of the backoffice allows Administrators to control which actions a user has permissions to access.

Display Modes

Entity Actions extensions can be displayed in a variety of formats.

The sidebar context mode provides a second-level context menu that flies out from the content tree. Backoffice users will typically find default items such as sorting, moving, deleting, and publishing workflow actions here.

graphic representation of the sidebar context menu

Workspace Entity Menu

The workspace entity mode provides a drop-down menu that flies out from the upper decking of a workspace.

Workspace Entity Action Menu

Collection Menu

The collection mode provides a drop-down menu that appears above a collection view.

Collection

Picker Menu

The picker mode provides a menu in a sidebar modal.

Pickers

Registering an Entity Action

To register an entity action, developers declare the entity action in the manifest file, and then extend the UmbEntityActionBase class to program the action's behavior.

Declare the Entity Action

The Entity Action Class

Umbraco provides a few generic actions that can be used across silos, such as copy, move, and trash. Umbraco may include additional generic actions in the future.

Entity Action extensions will need to supply a class to the extension definition using the api property in the manifest file. This class will be instantiated as part of the action and will be passed a reference to the entity that invoked it.

The Entity Action class will provide one of the following methods:

  • getHref - returns a URL that will be used for navigation.

  • execute - programs custom imperative behaviors that can work with contexts and service APIs.

If both methods are provided in the entity action class, the getHref method will be preferred.

When the action is completed, an event on the host element will be dispatched to notify any surrounding elements.

The getHref() Method

Entity action extensions are provided this.args by the UmbEntityActionBase superclass. The this.args contains a unique property that allows developers to identify which element the user selected.

The getHref() method must return a string value, and the result will be rendered into the DOM as an anchor/link.

The execute() Method

The execute() method is flexible and allows developers to perform nearly any task on an entity. Developers can perform network requests using fetch(), or access a repository.

The Executing Requests article provides an overview of the methods for fetching data from Umbraco, including tryExecute() requests.

Overriding the UmbEntityActionBase Constructor

If additional contexts are needed, they can be consumed from the host element via the constructor method.

User Permission Codes

Developers can define custom user permission codes to control access to their actions, in addition to the standard Umbraco user permission codes. Custom permission codes need to be unique and should not clash with existing permission codes.

Each permission has a set of verbs that will be checked against on both the client and server.

Standard Umbraco Permission Letters

Legacy backoffice letter
Verb

C

Umb.Document.Create

F

Umb.Document.Read

A

Umb.Document.Update

D

Umb.Document.Delete

I

Umb.Document.CreateBlueprint

N

Umb.Document.Notifications

U

Umb.Document.Publish

R

Umb.Document.Permissions

Z

Umb.Document.Unpublish

O

Umb.Document.Duplicate

M

Umb.Document.Move

S

Umb.Document.Sort

I

Umb.Document.CultureAndHostnames

P

Umb.Document.PublicAccess

K

Umb.Document.Rollback

Custom Permission Letters

Developers who create packages with custom entity actions are encouraged to update this document by submitting pull requests to the documentation repository. This will inform other developers which permission letters they should avoid defining.

Custom Backoffice letter
Verb

Placeholder

Entity Action Permissions

Umbraco provides two extension types for user permissions: entity user permissions and granular user permissions.

These two extension types are used in tandem with each other.

  • entityUserPermission: Defines what can be done and allows assigning them globally to a User Group.

  • userGranularPermission: Defines how those same verbs can be assigned to specific nodes in the User Management UI. These extension types provide an interactive interface in the backoffice to control permission assignment.

Entity User Permissions

Entity user permissions are assigned to entities like documents, media, and members. They are registered using the entityUserPermission type in the extension's manifest.

Management Interface

The entityUserPermission extension type will render a toggle control in the Default permissions pane in the Users > User Groups editor.

Entity User Permissions UI

Granular User Permission

Default Granular User Permission UI

Management Interface

Extension developers can customize the selection and interaction style of a granular permission using the element property. The element property accepts the file location of a custom web component, and will render that component in the management interface.

The userGranularPermission extension type will render a document selection control in the Granular permissions pane in the Users > User Groups editor by default. The default selector can be replaced with a custom web component.

Custom Granular User Permission UI

Enforcing Permissions

Developers can enforce permission controls on Entity Action extensions by defining conditions in the conditions array.

In the following example, the conditions:alias property of an entityAction extension matches the alias property of the entityUserPermission extension definition.

Similarly, the conditions:allOf array must contain the one of the values from the meta:verbs array of the entityUserPermission extension definition.

Last updated

Was this helpful?