Dynamic styleClass in web-item

Hello everyone,

Bitbucket Server has this neat little feature of highlighting entries in the Administration overview if something is not configured:

I tried to reproduce this for one of our plugins. My idea was to use a ContextProvider, which determines the content for the label and the styleClass. Here is the coresponding definition of the web-item from the plugin.xml:

<web-item name="Secure Login Admin Config Web Item" key="secureloginAdminConfigWebItem" section="atl.admin/secureloginAdminWebSection">
        <label>Secure Login Config</label>
        <context-provider class="de.syracom.bitbucket.plugins.securelogin.admin.AdminConfigContextProvider" />

In result the description (or tooltip in case of Bitbucket) get filled with the value the ContextProvider puts into the context map. But this does not seem to work in case of the styleClass attribute. As you can see from the generated html code, the $styleClass variable does not get replaced:

<a href="/bitbucket/plugins/servlet/twofactor/admin" class="$styleClass" title="Active configuration for the Secure Login plugin." data-web-item-key="de.syracom.bitbucket.plugins.securelogin:secureloginAdminConfigWebItem">Secure Login Config</a>
<span class="description">Active configuration for the Secure Login plugin.</span>

Does anyone know, if there is a way to fill the styleClass Attribute over the context or another way to archive the desired effect to change the style of the description based on state of the plugin?


In case someone else runs into the same question as me: a valid workaround is, to define two web-items with a condition, based on the state:

<web-item name="Secure Login Admin Configured Web Item" key="secureloginAdminConfiguredWebItem" section="atl.admin/secureloginAdminWebSection">
        <label key="securelogin.webitem.admin.config.label"/>
        <tooltip key="securelogin.webitem.admin.config.tooltip.configured"/>
        <condition class="de.syracom.bitbucket.plugins.securelogin.admin.PluginConfiguredCondition"/>
        <resource type="download" name="securelogin.css" location="/css/securelogin.css"/>

    <web-item name="Secure Login Admin Not Configured Web Item" key="secureloginAdminNotConfiguredWebItem" section="atl.admin/secureloginAdminWebSection">
        <label key="securelogin.webitem.admin.config.label"/>
        <tooltip key="securelogin.webitem.admin.config.tooltip.unconfigured"/>
        <condition class="de.syracom.bitbucket.plugins.securelogin.admin.PluginConfiguredCondition" invert="true"/>
        <resource type="download" name="securelogin.css" location="/css/securelogin.css"/>

But I would be still interested, if there is a more elegant way, to archive this.