A web fragment is a link, a section of links or an area of HTML content (or 'panel') in a particular location of the Bitbucket Server web interface. A web fragment could be a menu in Bitbucket Server's top navigation bar (which in itself may contain its own links and link sections), buttons on the project listing or panels on the commit page. Generally the content for web fragments are generated on the server, however Bitbucket Server also supports client web fragments.
A web fragment is one of six kinds of plugin module:
Web items or web sections are utilized in a number of different ways, depending on the location of the web fragment you are creating. Note that client web fragments have some additional things to consider.
You can view all available UI plugin points on a page by adding certain query parameters to the URL of any page in Bitbucket Server.
Simply add one or more of the following query parameters to the URL for any existing Bitbucket Server view:
|web.items||Display available Web Item and Client Web Item locations|
|web.panels||Display available Web Panel and Client Web Panel locations|
|web.sections||Display available Web Section and Client Web Section locations|
Bitbucket Server will then render example web items in all available pluggable locations.
For example, to find all web panels on a repository browse page:
Available web panel locations are rendered in red and any relevant objects which are available in the context are listed.
You can add multiple query parameters to see different types of web fragments. For example:
Would display all web item, web panel and web section locations on the repository browse page.
You can insert custom web fragments into existing ones in Bitbucket Server (e.g. web sections which are 'built in' to Bitbucket Server). However, you cannot redefine Bitbucket Server's existing web fragments.
We recommend downloading the Bitbucket Server source archive, so you can access the appropriate source files that define Bitbucket Server's existing web fragments. This will help you:
Conditions can be added to the web section, web item and web panel modules, to display them only when all the given conditions are true.
Condition elements must contain a class attribute with the fully-qualified name of a Java class. The referenced class:
To add a condition to your web section, web item or web panel, add the element as follows:
Condition elements can take optional parameters. These parameters will be passed in to the condition's init() method as a map of string key/value pairs after autowiring, but before any condition checks are performed. For example:
1 2 3
<condition class="com.atlassian.bitbucket.web.conditions.HasGlobalPermissionCondition"> <param name="permission">ADMIN</param> </condition>
To invert a condition, add the attribute to the condition element. This is useful where you want to show the section if a certain condition is not satisfied. Conditions elements are composed of a collection of condition/conditions elements and a type attribute. The type attribute defines what logical operator is used to evaluate its collection of condition elements. The type can be one of or .
For example: The following condition is true if the current user is a system administrator AND the mail server is configured:
1 2 3 4 5 6
<conditions type="AND"> <condition class="com.atlassian.bitbucket.web.conditions.IsMailServerConfiguredCondition"/> <condition class="com.atlassian.bitbucket.web.conditions.HasGlobalPermissionCondition"> <param name="permission">SYS_ADMIN</param> </condition> </conditions>
Here is an example atlassian-plugin.xml file containing a single web item:
1 2 3 4 5 6
<web-item key="repositories-menu" name="Repositories Global web item" weight="30" section="header.global.primary"> <condition class="com.atlassian.bitbucket.web.conditions.IsLoggedInCondition"/> <label key="bitbucket.web.menu.repositories">Repositories</label> <link linkId="repositories-menu-trigger">/</link> <styleClass>recent-repositories</styleClass> </web-item>
Many convenient conditions are provided by Bitbucket Server. A full list can be found in our documentation.