Conditional logic for a web-item plugin

<web-item key="vacCalendar_link" name="Vacation Calendar" section="my_links_link/my_links_section" weight="10">
<label>Vacation Calendar</label>
<link linkId="vacCalendar_link">javascript:void('$','test','width=800, height=800'));

I have added the above web-item plugin in atlassian-plugin.xml

I have another requirement now :

If the logged in user is a developer on click of the above link i want that he should be able to access URL1 but if the logged in user is a Project Manager/Lead he should be able to access URL2.

I am aware that any custom condition can be written by making our java class extend the com.atlassian.jira.plugin.webfragment.conditions.AbstractJiraCondition.But how do i mention links based on the condition.



1 answer

1 accepted

You just have to create two <web-item> elements and each of them will have different condition. The web-items will be the same except the condition and the link. When the user is a developer he'll see the first web-item and the second will not be rendered as its condition will not match, and if the user is project manager/lead he'll see the second web-item and the first will not be rendered.

I think you'll have to create your own condition to check if the user is a developer or project lead. See here for more information on how to define and use the condition

Thanks for your help Boris...You are a genious...:)

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
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

379 views 1 18
Join discussion

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