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
Community showcase
Posted Sep 25, 2018 in Jira

Atlassian Research Workshop opportunity on Sep. 28th in Austin, TX

We're looking for participants for a workshop at Atlassian! We need Jira admins who have interesting custom workflows, issue views, or boards. Think you have a story to sha...

455 views 7 5
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