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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Fadoua M. Boualem
Published Monday in Trello

Using Trello to manage events

As a Jira power user, I was at first doubtful that Trello could benefit my workflow. Jira already uses boards (ones you can customize!), so why would I even need to use Trello?! In this post you will...

502 views 8 9
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