How do I add a condition to restrict web panel on a issue view screen? Edited

I need some help in defining a condition based on IssueType:

The code I have written so far:

I need some help in defining a condition based on IssueType:
The code I have written so far:
import com.atlassian.jira.config.IssueTypeManager;
import com.atlassian.jira.issue.issuetype.IssueType;
import com.atlassian.plugin.PluginParseException;
import com.atlassian.plugin.spring.scanner.annotation.component.Scanned;
import com.atlassian.plugin.spring.scanner.annotation.imports.ComponentImport;
import com.atlassian.plugin.web.Condition;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.Map;

/**
*
*/

@Scanned
public class IssueTypeCondition implements Condition {

private IssueType mainIssueType;
private final String projectDataIssueTypeName = "Project Data";
private final IssueTypeManager issueTypeManager;

@Autowired
public IssueTypeCondition(@ComponentImport IssueType mainIssueType, @ComponentImport IssueTypeManager issueTypeManager){

this.mainIssueType = mainIssueType;
this.issueTypeManager = issueTypeManager;

}

public IssueType getIssueTypeByName(){

for (IssueType issueType : issueTypeManager.getIssueTypes()){
if (issueType.getName().equals(projectDataIssueTypeName)){
mainIssueType = issueType;
}
}
return mainIssueType;
}

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


public boolean shouldDisplay(Map<String, Object> context) {
mainIssueType = getIssueTypeByName();
if (mainIssueType != null){
return true;
} else {
return false;
}
}
}

But this condition does not seem to work right now

0 answers

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Jira

5 ways you can make the most of Jira Software and Bitbucket Cloud

As part of the Bitbucket product team I'm always interested in better understanding what kind of impact the use of our tools have on the way you work. In a recent study we conducted of software devel...

82 views 0 5
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you