Show my add-on only in some project

Brahim ESSALIH July 25, 2016

Hello every body,

I develooped an add-on, using spring-boot, for my coud instance. I want that my add-on dipslayed only in the project X and not in the others.

this is my desciptors:

{
	"key": "com.company.issue.showorders",
	"baseUrl": "https://f0a89b9a.ngrok.io",
	"name": "Show Orders project",
	"description": "Show a list of orders",
	"vendor": {
		"name": "test",
		"url": "http://www.my-company.com"
	},
	"authentication": {
		"type": "jwt"
	},
	"lifecycle": {
		"installed": "/installed",
		"uninstalled": "/uninstalled",
		"enabled": "/enabled",
		"disabled": "/disabled"
	},
	"apiVersion": 1,
	"scopes": [
		"read",
		"write"
	],
	"modules": {
		"webPanels": [
			{
				"url": "/showOrders?issueKey={issue.key}&projectKey={project.key}",
				"location": "atl.jira.view.issue.right.context",
				"layout": {
					"width": "100%",
					"height": "100%"
				},
				"conditions": [
					{
						"invert": "false",
						"params": {
						},
						"condition": "user_is_logged_in"
					}
				],
				"key": "list-orders-key",
				"name": {
					"value": "La liste des commandes"
				}
			}
		]
	}
}

 do you have any ideas how can I resolve that problem ?

 

Thank you for all your answers

1 answer

1 accepted

2 votes
Answer accepted
Petar Petrov (Appfire)
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 25, 2016

You need to use a condition (similar to "user_is_logged_in" which you have used above). One option is to store a entity property on the project which enables your functionality for that particular project and use a property condition to check for that property. If the property is set for a given project, you panel will be shown. You need to figure out how to set that property - one option is to expose some kind of administrative UI, where admin users can add projects, for which your panel will be shown. Or if this is just an internal add-on, you can set the property manually via REST for a given project.

Robert Massaioli _Atlassian_
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 25, 2016

Project Entity Properties are the correct answer to this problem. I would only add a link to the documentation to make this good answer complete: https://developer.atlassian.com/static/connect/docs/latest/concepts/hosted-data-storage.html

Brahim ESSALIH July 26, 2016

Thank you guys it work. I would only add some informations about how I did:

to create a property Entity for a "project" type like snippet below,  I use rest API:

PUT: https://my-cloud-instance.net/rest/api/2/project/{project-key-or-id}/properties/{propertyKey}
 
the Body of my PUT request:
{"isEnabled":true}

then in my descriptor I add a condition like that:


"displayAddonTest" is my {propertyKey}

 

....
"modules": {
		"webPanels": [
			{
				"url": "/showOrders?issueKey={issue.key}&projectKey={project.key}",
				"location": "atl.jira.view.issue.right.context",
				"conditions": [
					{
						"condition": "user_is_logged_in"
					},
					{
						"condition": "entity_property_equal_to",
						"params": {
							"entity": "project",
							"propertyKey": "displayAddonTest",
							"objectName": "isEnabled",
							"value": "true"
						}
					}
				],
				"key": "x-issue",
				"name": {
					"value": "Test"
				}
			}
		],
 
....



Suggest an answer

Log in or Sign up to answer