Portal Actions

Portal Actions#

Plone has the concept of configurable actions called portal_actions. Each action defines an id, a title, the required permissions, and a condition that will be checked to decide whether the action will be available for a user. Actions are sorted by categories.

Actions can be used to build UI elements that adapt to the available actions. An example is the Plone toolbar where the object_tabs (view, edit, folder contents, sharing) and the user_actions (login, logout, preferences) are used to display to the user only those actions that are allowed for the currently logged in user.

The available actions for the currently logged in user can be retrieved by calling the @actions endpoint on a specific context. This also works for unauthenticated users.

Listing available actions#

To list the available actions, send a GET request to the @actions endpoint on a specific content object:

http

GET /plone/@actions HTTP/1.1
Accept: application/json
Authorization: Basic YWRtaW46c2VjcmV0

curl

curl -i -X GET http://nohost/plone/@actions -H "Accept: application/json" --user admin:secret

httpie

http http://nohost/plone/@actions Accept:application/json -a admin:secret

python-requests

requests.get('http://nohost/plone/@actions', headers={'Accept': 'application/json'}, auth=('admin', 'secret'))

The server will respond with a 200 OK status code. The JSON response contains the available actions categories (object, object_buttons, user) on the top level. Each category contains a list of the available actions in that category:

HTTP/1.1 200 OK
Content-Type: application/json

{
  "object": [
    {
      "icon": "", 
      "id": "view", 
      "title": "View"
    }, 
    {
      "icon": "", 
      "id": "edit", 
      "title": "Edit"
    }, 
    {
      "icon": "", 
      "id": "folderContents", 
      "title": "Contents"
    }, 
    {
      "icon": "", 
      "id": "history", 
      "title": "History"
    }, 
    {
      "icon": "", 
      "id": "local_roles", 
      "title": "Sharing"
    }
  ], 
  "object_buttons": [
    {
      "icon": "", 
      "id": "cut", 
      "title": "Cut"
    }, 
    {
      "icon": "", 
      "id": "copy", 
      "title": "Copy"
    }, 
    {
      "icon": "", 
      "id": "delete", 
      "title": "Delete"
    }, 
    {
      "icon": "", 
      "id": "rename", 
      "title": "Rename"
    }
  ], 
  "user": [
    {
      "icon": "", 
      "id": "preferences", 
      "title": "Preferences"
    }, 
    {
      "icon": "", 
      "id": "plone_setup", 
      "title": "Site Setup"
    }, 
    {
      "icon": "", 
      "id": "logout", 
      "title": "Log out"
    }
  ]
}

If you want to limit the categories that are returned, pass one or more categories:list parameters, for example, @action?categories:list=object&categories:list=user.