Page tree
Skip to end of metadata
Go to start of metadata

An action bar organizes actions into sections and groups. The bar is typically displayed on the right hand side of an app. In content apps, the browser subapp has an action bar that allows the user to manage content items  (add, edit, delete).

The action bar also defines availability rules that determine which section of the action bar is displayed to the user. For example, when the user selects a content item, you want to only display actions that are relevant for that item.

The action bar references actions which are defined elsewhere. This separation allows you define an action once and use it in many places, not only in the action bar.

Action bar definition properties

Example: Action bar in the Contacts app.

browser:
    actionbar:
      defaultAction: editContact
      sections:
        - name: root
          # group definition
        - name: deletedContact
          # group definition
        - name: deletedFolder
          # groups definition
        - name: contact
          groups:
            - name: addActions
              items:
                - name: addContact
                - name: confirmDeleteContact
            - name: editActions
              items:
                - name: editContact
                - name: renameContact
            - name: activationActions
              items:
                - name: activate
                - name: deactivate
            - name: importExportActions
              items:
                - name: export
            - name: versionsActions
              items:
                - name: showVersions
                - name: restoreVersion
          availability:
            nodeTypes:
              mgnl-contact: mgnl:contact      
Node nameValue

 browser

 

 actionbar

 

 sections

 

 root

 

 deletedContact

 

 deletedFolder

 

 contact

 

 groups

 

 addActions

 

 items

 

 addContact

 

 confirmDeleteContact

 

 editActions

 

 items

 

 editContact

 

 renameContact

 

 activationActions

 

 items

 

 activate

 

 deactivate

 

 importExportActions

 

 items

 

 export

 

 versionsActions

 

 items

 

 showVersions

 

 restoreVersion

 

 availability

 

 nodeTypes

 

 mgnl:contact

mgnl:contact

 defaultAction

editContact

 

Properties:

actionbar

required

Action bar configuration.

sections

required

Sections defined in the bar.

<section name>

required

Arbitrary name. Name your sections after what the user has selected, such as folder when a folder is selected.

groups

required

Groups are actions that belong together. They are separated by horizontal lines in the action bar.

<group name>

required

Arbitrary name.

items

required

Node containing the action names.

<action name>

required

Name of the action. Must be the same as defined in the action definition.

availability

optional

Defines whether the section is displayed to the user. This typically depends on what type of node the user has selected.

label

optional

The section label is the green text displayed to users on the action bar.

defaultAction

optional

Name of the action executed when the user double-clicks an item.

Availability

Action bar availability defines whether a particular section of the action bar is available.

For example, in the action bar configuration in the Contacts app:

  • Actions in the root section display on the root node only. The user sees the Add contact, Add folder and Import actions defined in the groups in the root section.
  • Actions in the contact section display on selection of a mgnl:contact node type.
  • Actions in the deletedContact section display on selection of a mgnl:contact node type, but the IsDeletedRule rule class limits action availability when a contact has been marked for deletion to the Publish deletion and Restore previous version actions. This rule returns true if the item is a node and has the mgnl:deleted mixin type.
actionbar:
  defaultAction: editContact
  sections:
    - name: root
      groups:
        # group definitions
      availability:
        nodes: false
        root: true
    - name: deletedContact
      groups:
        # group definitions
      availability:
        nodeTypes: 
          mgnl-contact: mgnl:contact
        rules:
          - name: isDeletedRule
            implementationClass: info.magnolia.ui.framework.availability.IsDeletedRule
    - name: deletedFolder
      # groups definition
    - name: contact
      groups:
        # group definitions
      availability:
        nodeTypes: 
          mgnl-contact: mgnl:contact
Node nameValue

 actionbar

 

 sections

 

 root

 

 groups

 

 availability

 

 nodes

false

 root

true

 deletedContact

 

 groups

 

 availability

 

 nodeTypes

 

 mgnl-contact

mgnl:contact

 rules

 

 isDeletedRule

 

 implementationClass

info.magnolia.ui.framework.availability.IsDeletedRule

 deletedFolder

 

 contact

 

 groups

 

 availability

 

 nodeTypes

 

 mgnl-contact

mgnl:contact

Properties

<section name>

required

Name of the action bar section

availability

required

Action availability configuration.

access

optional

Section is available if the current user has one of the listed roles.

roles

required

Section is available to users assigned the listed roles.

<role>

required

Name of the role that is permitted to execute the action.

nodes

optional

Section is available if the selected item is a node.

nodeTypes

optional

Section is available if the selected item is one of the node types listed.

<node type>

required

A valid node type such as mgnl:folder.

rules

optional

Rules configuration node

<rule name>

required

Rule configuration node. One node for each rule. Node name is arbitrary.

implementationClass

required

Class that contains custom logic to check if the action is permitted on the selected item. A common example is info.magnolia.ui.framework.availability.IsNotDeletedRule which checks that the item is not marked for deletion. Your custom class must extend AbstractAvailabilityRule .

root

optional

Action is available at the workspace root level if true.

properties

optional

Action is available if the selected item is a property.

Here's the action bar:

  • With no selection.
  • When a contact is selected.
  • After a contact is deleted.

    

Action bar availability is different from action availability where availability rules are defined on an individual action level and apply to each use of the action. 

1 Comment

  1. Please note that the first available section (based on the availability configuration) will be shown. So sections that define rules like the info.magnolia.ui.framework.availability.IsDeletedRule should be ordered before the sections that don't have any availability configuration. See the info.magnolia.ui.contentapp.browser.BrowserSubApp#getVisibleSection() method.