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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

167 views 1 17
Join discussion

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