Adding conditions for web fragments
As we saw in the previous recipes, adding a web fragment is pretty easy. However, the job doesn't always stop there. In many cases, we would want to limit the web item based on a set of conditions.
For example, an Edit link on an issue should only appear for people with edit permission on that issue. The Administration link should appear only if the user is a JIRA Administrator. In this recipe, let us look at how we can implement conditions for displaying web fragments.
How to do it...
It is possible to add one or more conditions to a web section or a web item. In the latter case, the conditions
element is used, which is a collection of condition
/conditions
elements and a type
attribute. The type
attribute is either the logical AND
or OR
.
For example, the following condition specifies that the user should have either the admin
or use
permission in a project before he/she can see the web fragment that has the condition on it:
<conditions type="OR"> ...