Show my add-on only in some project

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

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.

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

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
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

78 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you