Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

how to get current issue in Condition class?

Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2015

Hello !

So I have this web-panel:

<web-panel key="mypanel" name="my panel" location="atl.jira.view.issue.right.context">
        <condition class="my.IssueCondition" />
        <resource name="view" type="velocity" location="templates/panelview.vm"/>
    </web-panel>

 

I tried to get the current Issue in the IssueCondition.class :

public class IssueCondition implements Condition{
    
    private JiraHelper helper;
    
    public IssueCondition(JiraHelper helper){
        this.helper = helper;
		Issue currentIssue = (Issue) helper.getContextParams().get("Issue");
    }
...

 

This code doesnt work! Seems like JiraHelper is not injectable or... Condition classes are not CDI aware?

 

Thanks for help!

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

2 votes
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2015

Make your condition to inherit from AbstractIssueWebCondition and Jirahelper is passed to shouldDisplay:

public class IssueCondition implements AbstractIssueWebCondition {   
 
  ...

  @Override
  public boolean shouldDisplay(final ApplicationUser user, final Issue issue, final JiraHelper jiraHelper) {
    ...
  }
 
  ...
0 votes
Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2015

Ahh I found the AbstractIssueCondition class:https://docs.atlassian.com/jira/6.4.3/com/atlassian/jira/plugin/webfragment/conditions/AbstractIssueCondition.html

This might be exactly what I need

Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 25, 2015

Yes this works, but this classes are deprecated. This means it works also with older jira versions. if you want to be modern, look at the accepted answer

TAGS
AUG Leaders

Atlassian Community Events