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

Alok Singh October 18, 2017

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