How to make custom button to be visible or unvisible with plugin code

How to make custom button to be visible or unvisible with plugin code ?

I develop a webitem button in opsbar-transitions.

  • Environment : Jira Server
  • button name : “Approval”

But there is an issue about visibility of the button according to issue status.
So to speaking, I want to hide the button in opsbar-transitions at specific status of issue,
and to show the button in opsbar-transitions at another status of issue.

How can I control the button visibility with java code ?

Anyone you know, please help !

Hello, you can use Conditions on Web Items. The documentation is here:

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:

  • must implement com.atlassian.plugin.web.Condition, and
  • will be auto-wired by Spring before any condition checks are performed.

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:

I’ve provided a somewhat more complete example stolen from one of my projects.

  <condition class="com.sbehnke.example.MyCustomIssueCondition">
    <param name="project">PROJ</param>
    <param name="issueType">Bug</param>
  <condition class="com.sbehnke.example.MyCustomStatusCondition">
    <param name="status">Open</param>
package com.sbehnke.example;

import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.plugin.webfragment.conditions.AbstractWebCondition;
import com.atlassian.jira.plugin.webfragment.model.JiraHelper;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.plugin.PluginParseException;

import javax.inject.Named;
import java.util.Map;

public class MyCustomIssueCondition extends AbstractWebCondition {
    private String projectKey;
    private String issueTypeName;

    public void init(Map<String, String> params) throws PluginParseException {

        this.projectKey = params.get("project");
        this.issueTypeName = params.get("issueType");

    public boolean shouldDisplay(ApplicationUser applicationUser, JiraHelper jiraHelper) {
        final Issue issue = (Issue) jiraHelper.getContextParams().get("issue");
        if (issue == null) {
            return false;

        final String projectKey = issue.getProjectObject().getKey();
        final String issueTypeName = issue.getIssueType().getName();

        return projectKey.equalsIgnoreCase(this.projectKey) &&
1 Like

Thanks. I will try ~~

1 Like