You can no longer publish Connect apps on the Atlassian Marketplace. All new extensibility features will be delivered only on Forge.
Refer to this blog post for our timeline to end Connect support.
Have an existing Connect app? You can incrementally migrate it to Forge.
Connect conditions are a powerful way to control whether your UI elements should be shown or not. A common example is to specify that a user must be logged in to see the app. Or, you may want your element to always display but behave differently depending on user permissions or other states that conditions allow you to check.
You should not rely on Connect conditions as a mechanism to protect sensitive data. This is because conditions are executed on the client-side, and it is impossible to guarantee that the execution results won't be overridden using the developer tools of a browser.
We strongly recommend that you apply appropriate permission checks in your code on top of Connect conditions for any sensitive data you are going to operate with.
Predefined conditions provided by each host product are the most commonly used conditions. But, if you need more flexibility, custom conditions stored by the app in the host product is an option:
A predefined condition is a condition which is exposed from the host Atlassian application.
For example, a condition that will evaluate when only logged-in users view the page is specified by the following module declaration.
1 2{ "modules": { "generalPages": [ { "conditions": [ { "condition": "user_is_logged_in" } ] } ] } }
See the list of predefined conditions.
Certain predefined conditions accept parameters.
For example, the has_attachment_permission condition passes only for users who have the permission
specified in the condition. This means that permissions are checked when the user views the page in
a browser.
1 2{ "modules": { "generalPages": [ { "conditions": [ { "condition": "has_attachment_permission", "params": { "permission": "EDIT" } } ] } ] } }
There are a set of common conditions and Confluence-specific conditions.
addon_property_equal_toaddon_property_equal_to_contextaddon_property_contains_anyaddon_property_contains_alladdon_property_contains_contextaddon_property_contains_any_user_groupentity_property_equal_to_contextentity_property_contains_anyentity_property_contains_allentity_property_contains_contextentity_property_contains_any_user_groupfeature_flaguser_is_adminuser_is_logged_inuser_is_sysadminaddon_is_licensedcan_edit_space_stylescan_signupcontent_has_any_permissions_setcontent_property_equal_tocontent_property_equal_to_contextcontent_property_contains_anycontent_property_contains_allcontent_property_contains_contextcontent_property_contains_any_user_groupcreate_contentemail_address_publicfavourite_pagefavourite_spacefollowing_target_userhas_attachmenthas_attachment_permissionhas_blog_posthas_comment_permissionhas_custom_content_permissionhas_pagehas_page_permissionhas_spacehas_space_permissionhas_templatelatest_versionnot_personal_spaceprintable_versionshowing_page_attachmentsspace_function_permissionspace_property_equal_tospace_property_equal_to_contextspace_property_contains_anyspace_property_contains_allspace_property_contains_contextspace_property_contains_any_user_groupspace_sidebartarget_user_has_personal_blogtarget_user_has_personal_spacethreaded_commentstiny_url_supporteduser_can_create_personal_spaceuser_can_use_confluenceuser_favouriting_target_user_personal_spaceuser_has_personal_bloguser_has_personal_spaceuser_is_anonymoususer_is_confluence_administratoruser_is_external_collaboratoruser_is_licenseduser_logged_in_editableuser_watching_pageuser_watching_spaceuser_watching_space_for_content_typeviewing_contentviewing_own_profilehas_attachment_permission, has_comment_permission, has_custom_content_permission,
has_page_permission and has_space_permission require a key of the permission that will be
checked for the current user to be passed via the permission parameter. Below you will find the
keys of the valid permissions.
VIEWEDITSET_PERMISSIONSREMOVEEXPORTADMINISTERADMINISTERSYSTEM_ADMINUSER_PICKERCREATE_SHARED_OBJECTSMANAGE_GROUP_FILTER_SUBSCRIPTIONSBULK_CHANGEProperty conditions operate on properties of the user at the browser, the entity being viewed (e.g., a page or a blog post), or its container (e.g., a space), or the entire system.
Apps that need to impose custom requirements when user interface elements are displayed can use a property condition.
The following property conditions exist:
entity_property_equal_toentity_property_contains_anyentity_property_contains_allThese allow fast comparisons to be made against data (properties) stored by the app in the host product. See the Confluence entity properties page for more details. Usually, properties are set by a REST call against an entity type. See the Confluence Cloud REST API documentation for information about how to manage properties for each entity.
Using conditions with app or entity properties only controls what users see in the product UI. Authenticated users can access and edit properties using the REST APIs. For this reason, never use app or entity properties to store private or personal information.
Property conditions are defined in the atlassian-connect.json file in a similar way to built in
conditions. An example is below.
1 2{ "modules": { "webItems": [ { "key": "conditional-web-item", "name": { "value": "Conditional web item" }, "url": "/conditional-web-item", "location": "page.metadata.banner", "conditions": [ { "condition": "entity_property_equal_to", "params": { "entity": "content", "propertyKey": "example-key", "value": "example-value", "objectName": "state" } } ] } ] } }
The condition requires three parameters and can contain (as in the above example) an optional fourth parameter.
entity - the entity on which the property has been stored. If an entity of the expected type is
not present in the
rendering context of the user interface element, the condition evaluates to false.
content, spacepropertyKey - the key of the property to check. If the property is not present, the condition
evaluates to false.value - the value to compare the property value against.The optional parameter objectName lets you select which part of the entity property JSON value
you wish to compare
against. For example, if an entity property had the following value:
1 2{ "one": { "ignored": "value", "two": true }, "also": "ignored" }
Then you could set the value parameter to true and the objectName parameter to one.two and
the condition would evaluate to true. Specifying an objectName string which cannot be used to
traverse the property value results in false.
An app could let administrators activate functionality per Confluence space. This could be achieved
by storing an entity property with the key mySettings and the value {"isEnabled" : true} on
each project using the product's REST API. Then use the entity_property_equal_to to test for it
with the following module definition:
1 2{ "modules": { "webPanels": [ { "location": "atl.confluence.view.space.right.context", "conditions": [ { "condition": "entity_property_equal_to", "params": { "entity": "space", "propertyKey": "mySettings", "objectName": "isEnabled", "value": "true" } } ] } ] } }
It is also possible to write conditions where you can check if one or all of the values in the condition are present in the hosted data.
For example, imagine that you stored the following data against a Confluence space under the property
key consumingTeams:
1 2{ "teamCount": 4, "teams": ["Legal", "Human Resources", "Accounting", "Taxation"] }
You could then write a condition to only apply to projects that are for the Accounting and
Development teams, like so:
1 2{ "condition": "entity_property_contains_any", "params": { "entity": "space", "propertyKey": "consumingTeams", "objectName": "teams", "value": "[\"Accounting\", \"Development\"]" } }
You will note that the value parameter needs to be a string escaped JSON element.
-->
The following aliases can be used which make writing property conditions more convenient.
addon_property_equal_toaddon_property_contains_anyaddon_property_contains_allcontent_property_equal_tocontent_property_contains_anycontent_property_contains_allspace_property_equal_tospace_property_contains_anyspace_property_contains_allWhen using these aliases, the entity param is not used. This would mean the following two
condition definitions are identical.
This definition...
1 2{ "condition": "entity_property_equal_to", "params": { "entity": "content", "propertyKey": "flagged", "value": "true" } }
...is the same as this definition.
1 2{ "condition": "content_property_equal_to", "params": { "propertyKey": "flagged", "value": "true" } }
The addon_is_licensed condition will evaluate to true if and only if your app is a paid
app and it is licensed. This condition can be placed on any Atlassian Connect module that
supports conditions, and it is not context sensitive. Here is an example of the new condition in use:
1 2"generalPages": [{ "conditions": [ { "condition": "addon_is_licensed" }, { "condition": "user_is_logged_in" } ], "key": "your-module-key", "name": { "value": "Your module name" }, "url": "/panel/for/page", "weight": 100 }]
In this example, the Jira Issue Tab Panel will only be shown if the app is licensed and the user is logged in.
The composite condition module fragment can be used wherever a condition is expected. This allows the construction of boolean expressions aggregating multiple conditions.
For example, a condition that will evaluate when only anonymous users view the page is specified by the following module declaration.
1 2{ "modules": { "generalPages": [ { "conditions": [ { "condition": "user_is_logged_in", "invert": false } ] } ] } }
Rate this page: