Enabling workflow in content apps

The Workflow module provides a four-eye content approval workflow preconfigured in the Pages app. It is possible, however, for any content app to have a workflow attached to it. If the app already exists, a decoration file can be used. For a custom content app, it is easiest to configure the workflow directly in the app descriptor.

Existing content apps

With out-of-the-box apps, the best approach is to use a decoration file. Using a decoration file allows you to change the configuration in a target app without having to update a YAML-based definition. For example, to add a workflow to the Assets app, override the configuration for the publish and unpublish actions.

/my-module/decorations/dam-app/apps/dam.yaml
subApps:
  jcrBrowser:
    actions:
      publish: !override &publish
        $type: openDialogAction
        dialogId: workflow-pages:publish
        icon: icon-publish
        availability:
          rules:
            notDeleted: &notDeleted
              $type: jcrIsDeletedRule
              negate: true
            isPublishable: &isPublishable
              $type: jcrPublishableRule
      publishRecursive: !override
        $type: openDialogAction
        dialogId: workflow-pages:publishRecursive
        icon: icon-publish-incl-sub
        availability:
          rules:
            notDeleted: *notDeleted
            hasSubPages:
              $type: jcrHasChildrenRule
              nodeTypes:
                - mgnl:folder
                - mgnl:asset
            isPublishable: *isPublishable
      unpublish: !override &unpublish
        $type: openDialogAction
        dialogId: workflow-pages:unPublish
        icon: icon-unpublish
        availability:
          rules:
            notDeleted: *notDeleted
            isPublished:
              $type: jcrPublishedRule
      publishDeletion: !override
        $type: openDialogAction
        dialogId: workflow-pages:publishDeletion
        icon: icon-unpublish
        availability:
          multiple: true
          rules:
            isDeleted: &isDeleted
              $type: jcrIsDeletedRule
              negate: false

Custom content apps

With custom apps, the best approach is to configure the actions directly in the YAML descriptor. Simply copy the actions from the above decoration file and paste them into the actions block of your browser subapp.

Configuration

The above is just one way to configure a workflow for the Assets app. Other options exist if you want to configure things differently.

Commands

The Workflow module provides two commands for publication (activate and deactivate) that can be configured in /modules/workflow/commands/workflow. Both activate and deactivate are command chains that call VersionCommand before the respective actions.

Scheduling

The above workflow supports scheduling, which is how the Pages app works out of the box. You can schedule publication and unpublication for a later date but still execute the workflow immediately.

Default scheduling is configured in the publish dialog. It is possible to disable scheduling by deleting publicationDate from the dialog.

form:
  properties:
    comment:
      $type: textField
      rows: 5
  publicationDate:
    $type: dateField
    time: true

actions:
  commit:
    class: info.magnolia.module.workflow.action.WorkflowCommandActionDefinition

Adding custom parameters

You can pass custom parameters from your action definition into the process using the params node in the action configuration. You can reference the parameters in the process as described in Input and output parameters.

actions:
  publish:
    $type: openDialogAction
    dialogId: workflow-pages:publish
    icon: icon-publish
    availability:
      rules:
        notDeleted: &notDeleted
          $type: jcrIsDeletedRule
          negate: true
        isPublishable: &isPublishable
          $type: jcrPublishableRule
    params:
      param1: value1
      param2: value2
Feedback