Web Panel
Web panels can be used to add HTML snippets to parts of a page. They could be used to display additional information on a particular build, a plan, or the system navigation. For more information, read up on web panels in the Atlassian documentation.
As a simple example, let’s imagine we want to inform editors of certain Confluence spaces or Jira projects that the space is to be deprecated, and we’d prefer that they updated a page in another space.
Choose the Show a web panel built-in script, and configure it as follows:
The weight field is optional, and it only takes positive integers. Lower weights will make the panel be displayed at the top of its section. If blank it will appear at the end of its section.
For the provider class/script try pasting in the following, either inline or into a file, and pointing to the file:
writer.write("<div style='background-color: yellow; text-align: center'>" + "This project is going to be deprecrated. Please create" + " all issues in the WIDGET project</div>")
This should appear only on issues in certain projects, eg:
You must write to the provided Writer object, not just return a String.
It would be preferable to have the message as the actual banner, but unfortunately the current project
object is not available to us in that context.
Parent Issue Example
This example shows how you can retrieve the current issue from the context
. The context
is just a Map, which is application specific, but in JIRA’s case contains the current issue, and a JiraHelper
.
The following web panel code:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.RendererManager def issue = context.issue as Issue def rendererManager = ComponentAccessor.getComponent(RendererManager) def fieldLayoutItem = ComponentAccessor.getFieldLayoutManager().getFieldLayout(issue).getFieldLayoutItem("description") def renderer = rendererManager.getRendererForField(fieldLayoutItem) if (issue.isSubTask() && issue.parentObject.description) { writer.write(renderer.render(issue.parentObject.description, null)) }
will produce something like (on the subtask):
The full configuration of the panel is below. Note that I have added a condition, although this is a little superfluous, as the panel is written to do nothing if it’s not a subtask, in which case the panel won’t be displayed at all:
Conditions
Conditions are largely the same as for web item conditions.