Rate this page:

Publish Conditions

publishConditions module allows you to block content publishing until conditions specified in this module are satisfied. All existing connect conditions are supported by this module.

Example

1
2
"{\n  \"modules\": {\n    \"publishConditions\": [\n      {\n        \"errorMessage\": {\n          \"value\": \"My error message\"\n        },\n        \"context\": \"addon\",\n        \"dialog\": {\n          \"height\": \"100px\",\n          \"url\": \"/your_api\",\n          \"conditions\": [\n            {\n              \"condition\": \"has_attachment\",\n              \"invert\": false\n            }\n          ],\n          \"header\": {\n            \"value\": \"My custom header\"\n          },\n          \"width\": \"500px\"\n        },\n        \"conditions\": [\n          {\n            \"or\": [\n              {\n                \"condition\": \"user_is_admin\",\n                \"invert\": false\n              },\n              {\n                \"condition\": \"has_attachment\",\n                \"invert\": false\n              }\n            ]\n          },\n          {\n            \"condition\": \"user_is_logged_in\",\n            \"invert\": false\n          }\n        ],\n        \"name\": {\n          \"value\": \"My Publish Condition\"\n        },\n        \"key\": \"my-publish-condition\"\n      }\n    ]\n  }\n}"

Properties

errorMessage
Type
Required
Yes
Description

An error message will help you to understand the issue and take necessary action to satisfy the publish condition.

Note: If dialog property is missing, it will be displayed as a notification in Confluence.

Represents a string that can be resolved via a localization properties file. You can use the same i18n Property key and value in multiple places if you like, but identical keys must have identical values.

Example

1
2
3
4
{
  "value": "My text"
}

Properties

value
Type
Max length
1500
Required
Yes
Description

The human-readable default value. This will be used if no translation exists. Only the following HTML tags are supported: b, i, strong, em, and code.

i18n
Type
Max length
300
Description

The localization key for the human-readable value. Translations for the keys are defined at the top level of the add-on descriptor.


key
Type
Max length
100
Required
Yes
Pattern
^[a-zA-Z0-9-]+$
Description

A key to identify this module.

This key must be unique relative to the add on, with the exception of Confluence macros: Their keys need to be globally unique.

Keys must only contain alphanumeric characters and dashes.

The key is used to generate the url to your add-on's module. The url is generated as a combination of your add-on key and module key. For example, an add-on which looks like:

1
2
3
4
5
6
7
8
9
{
    "key": "my-addon",
    "modules": {
        "configurePage": {
            "key": "configure-me",
        }
    }
}

Will have a configuration page module with a URL of /plugins/servlet/ac/my-addon/configure-me.


name
Type
Required
Yes
Description

A human readable name.

Represents a string that can be resolved via a localization properties file. You can use the same i18n Property key and value in multiple places if you like, but identical keys must have identical values.

Example

1
2
3
4
{
  "value": "My text"
}

Properties

value
Type
Max length
1500
Required
Yes
Description

The human-readable default value. This will be used if no translation exists. Only the following HTML tags are supported: b, i, strong, em, and code.

i18n
Type
Max length
300
Description

The localization key for the human-readable value. Translations for the keys are defined at the top level of the add-on descriptor.


conditions
Type
Description

Conditions can be added to display only when all the given conditions are true.


context
Type
Defaults to
addon
Allowed values
  • page
  • PAGE
  • addon
  • ADDON
  • product
  • PRODUCT
Description

The context for the URL parameter. As of now only supported value is addon.

  • addon - a URL relative to the add-on's base URL


dialog
Type
Description

Triggers the dialog on click of Publish button.

The dialog allows you to display their custom content within iFrame in the dialog during publish button click.

Trigger dialog close using postMessage

You can close dialog by sending postMessage with action = closeConditionalPublishDialog
1
2
3
4
5
6
7
8
9

  $(function(){
   setTimeout(() => {
     window.top.postMessage({
       action: "closeConditionalPublishDialog"
     }, AP._data.origin)
   }, 10000);
 })
 

Properties

url
Type
Format
uri-template
Required
Yes
Description

Specifies the destination of the dialog content. The interpretation of this field depends on the value of the

1
context

field.

Your add-on can receive additional context from the app by using variable tokens in the URL attribute.

conditions
Type
Description

Conditions can be added to display only when all the given conditions are true.

header
Type
Description

The header text for the dialog

Represents a string that can be resolved via a localization properties file. You can use the same i18n Property key and value in multiple places if you like, but identical keys must have identical values.

Example

1
2
3
4
{
  "value": "My text"
}
height
Type
Max length
10
Description

Sets how high the dialog is in pixels

width
Type
Max length
10
Description

Sets how wide the dialog is in pixels.


params
Type
Description

This object represents a map of key/value pairs, where each property name and value corresponds to the parameter name and value respectively.

Example

1
2
3
4
5
6
7
{
  "params": {
    "someOtherProperty": "someValue",
    "myCustomProperty": "myValue"
  }
}

Rate this page: