The provided webpack plugin uses annotations in comments to gather information about the extension, and generate the XML for you.
Name | Type | Description |
---|---|---|
@clientside-extension * | - | Indicates that the next function is an extension factory to be consumed by the webpack plugin. |
@extension-point * | string | Defines the location where the extension will be rendered. |
@weight | number |
Determines the order in which the extension appears respect to others in the same location. Extensions are displayed top to bottom or left to right in order of ascending weight. |
@condition | string | Condition, UrlReadingCondition |
Defines one or multiple conditions that must be satisfied for the extension to be displayed. The conditions are evaluated on the server, and created with Java. If one of the conditions is not met, the code of the extension won't be loaded in the client. For more information about the conditions please refer to the examples of Web items documentation. |
* required
The following annotations should no longer be used
Name | Type | Deprecated since | Planned removal |
---|---|---|---|
@label | string | 2.0 | 3.0 |
@link | string | 2.0 | 3.0 |
Instead of specifying the following as annotations it is recommended to provide these as attributes at runtime:
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @weight 100 */ export default LinkExtension.factory((api) => { return { label: 'My Link-Extension', url: '/my-link-extension', }; });
PageExtension
annotationsThe list of additional annotation that can be used with [PageExtension
]. Refer to the PageExtension
API to read more details about the supported annotations.
Name | Type | Description |
---|---|---|
@page-url * | string |
Defines an url of the web page. The page will be accessible at this url prefixed with Example: Using |
@page-title * | string | Defines a title of the web page. The value can be either a raw string or a property key than will be translated. |
@page-decorator | string |
A custom page decorator. The default value is List of built-in decorators supported by all products:
|
@page-data-provider | string |
A page data provider Java class. Page data providers can be used to provide a custom set of a server-side data into your browser page extension. To read more about the page data providers check the usage section. Example: |
* required for PageExtension
Name | Description |
---|---|
$key | When present in any annotation, $key will be replaced with the extension key generated by the CSE webpack plugin. |
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point */ export default LinkExtension.factory(/*...*/);
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @weight 100 */ export default LinkExtension.factory(/*...*/);
page-*
annotationsThe page-*
annotations can be used to create a custom web and render a navigation link in the product UI.
1 2/** * @clientside-extension * @extension-point example.extension.point * @page-url /my-admin-page * @page-title "My admin page" * @page-decorator atl.admin */ export default PageExtension.factory((container) => { container.innerHTML = '<div>Very secure page!</div>'; });
Refer to the PageExtension
API to read more details about the supported annotations.
For those cases where you need to know the value of the extension key and use it in the annotations, you can make use of the $key
keyword.
CSE webpack plugin will replace it with the actual value of the key that the plugin generates for your extension.
1 2import { PageExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @page-url /my-admin-page?q=$key * @page-title "My admin page" */ export default PageExtension.factory((container) => { container.innerHTML = '<div>Very secure page!</div>'; });
The @condition
annotation allows you to define one or multiple conditions that must be satisfied for the extension to be displayed.
These conditions are evaluated on the server and are implemented in Java. They are used for determining if the extension should be downloaded and rendered by the client. For compatibility reasons, the condition class needs to implement both com.atlassian.plugin.web.Condition
and com.atlassian.webresource.spi.condition.UrlReadingCondition
interfaces, and both implementations should yield the same result.
For more information about the condition's usage please refer to the examples of Web items documentation and check the documentation of conditionMap
option from atlassian-webresource-webpack-plugin
.
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @condition class com.atlassian.cse.demo.RandomCondition */ export default LinkExtension.factory(/*...*/);
1 2public class RandomCondition implements Condition, UrlReadingCondition { // Condition implementation @Override public void init(Map<String, String> map) { } @Override public boolean shouldDisplay(Map<String, Object> map) { // ... } // UrlReadingCondition implementation @Override public void addToUrl(UrlBuilder urlBuilder) { // ... } /** * Needs to be the same result as {@link #shouldDisplay(Map)} */ @Override public boolean shouldDisplay(QueryParams queryParams) { // ... } }
To add parameters to the conditions you can use multiple @condition
annotations. These parameters will be passed in to the condition's init()
method as a map of string key/value pairs.
The first part of @condition
annotation is a property path, and the second part is the property value.
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @condition class com.atlassian.cse.demo.RandomCondition * @condition params.0.attributes.name permission * @condition params.0.value admin * @condition params.1.attributes.name location * @condition params.1.value menu */ export default LinkExtension.factory(/*...*/);
These @condition
annotations will result in creating a condition map object that is matching the shape of conditionMap
option from atlassian-webresource-webpack-plugin
:
1 2{ "class": "com.atlassian.cse.demo.RandomCondition", "params": [ { "attributes": { "name": "permission" }, "value": "admin" }, { "attributes": { "name": "location" }, "value": "menu" } ] }
You can make use of AND / OR keywords to combine multiple conditions for your extension as follows:
1 2import { LinkExtension } from '@atlassian/clientside-extensions'; /** * @clientside-extension * @extension-point example.extension.point * @condition type AND * @condition conditions.0.type OR * @condition conditions.0.conditions.0.class com.atlassian.cse.demo.RandomCondition * @condition conditions.0.conditions.0.invert true * @condition conditions.0.conditions.0.params.0.attributes.name permission * @condition conditions.0.conditions.0.params.0.value admin * @condition conditions.0.conditions.1.class com.atlassian.cse.demo.SuperCondition * @condition conditions.0.conditions.1.invert true * @condition conditions.0.conditions.1.params.0.attributes.name permission * @condition conditions.0.conditions.1.params.0.value project * @condition conditions.1.class com.atlassian.cse.demo.PerfecCondition * @condition conditions.1.params.0.attributes.name permission * @condition conditions.1.params.0.value admin */ export default LinkExtension.factory(/*...*/);
These @condition
annotations will result in creating a condition map object that is matching the shape of conditionMap
option from atlassian-webresource-webpack-plugin
:
1 2{ "type": "AND", "conditions": [ { "type": "OR", "conditions": [ { "class": "com.atlassian.cse.demo.RandomCondition", "invert": true, "params": [ { "attributes": { "name": "permission" }, "value": "admin" } ] }, { "class": "com.atlassian.cse.demo.SuperCondition", "invert": true, "params": [ { "attributes": { "name": "permission" }, "value": "project" } ] } ] }, { "class": "com.atlassian.cse.demo.PerfectCondition", "params": [ { "attributes": { "name": "permission" }, "value": "admin" } ] } ] }
Rate this page: