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 onweb panelsin the Atlassian documentation.
Examples
Deprecated Space Notification
You can inform editors that a certain Confluence space will be deprecated, so they should update a page in another space.
Choose theShow a Web Panelfragment.
Fill out the form:
The weight field is optional, and it only takes positive integers. Lower integers make the panel appear at the top of the section. If the field is blank, appears at the end of the section.
Add the following code to theProvider Class/Scriptfield:
writer.write("<div style='background-color: yellow; text-align: center'>" +
"This space is going to be deprecrated. Please move" +
" all content to the DOCS space</div>")
CODE
This is the result of the above web panel, which should only appear in the specified space:
You must write to the providedwriterobject not just return astring.
Service Management Portal
You can display a web panel for a specific Jira Service Management portal in theservicedesk.portal.headerlocation. . Create a web panel. . Enter this in theConditionsection:
portal.id == 1
CODE
This code works in a portal window as the binding variable portal is available in Service Management portal context. But the code throws a groovy missing property exception in the user window because the variable is not available in a Service Management user window. To avoid this kind of scenario, check the availability of the variable, where applicable:
binding.variables.get("portal") && portal.id == 1
CODE
Test the script in different contexts to avoid unexpected errors. If necessary in the script, check availability of the variables to avoid exceptions.