HI,
I wanted to show the plugin web panel based on the issue type and the component matched it not then simply it should not display it.
What I did is...in java class i get the issue type and components and put to context map and the same checking in the .vm file like
if ($issueType == "Task" && CompName == 'Jira')
//display
#end
But in this the panel is displaynig on Task and other issue types.
If the issue type is Task and component is Jira then it's displaying as expected but if the issue type is Bug then also the web panel is displaying with an error.
So if the condition does not match (issue type and component) then the web panel should not display.
Any help would be appreciated.
Thanks,
Yogesh
You need two things:
Add a condition to your web panel in atlassian-plugin.xml
<web-panel name="My Issue Panel" i18n-name-key="my-issue-panel.name" key="my-issue-panel" location="atl.jira.view.issue.right.context" weight="10">
<description key="my-issue-panel.description">meaningful description here</description>
<context-provider class="com.example.views.PracticeIssuePanelContextProvider"/>
<resource name="view" type="velocity" location="templates/my-issue-panel.vm"/>
<condition class="com.example.views.MyWebPanelCondition"/>
</web-panel>
and implement an AbstractWebCondition
public class MyWebPanelCondition extends AbstractWebCondition {
@Override
public boolean shouldDisplay(ApplicationUser user, JiraHelper helper){
Issue currentIssue = (Issue) helper.getContextParams().get("issue");
Project currentProject = currentIssue.getProjectObject();
Boolean validProject = (
currentProject.getKey().equals("ABC")
|| currentProject.getKey().equals("XYZ")
);
return validProject;
}
}
Good luck!
Thanks for your response.
Actually i tried the same before but the problem is same condition I added to .vm file as well hence it's not working previously.
After removing the .vm file condition its working fine.
Also, one more question, I wanted to fetch the insight custom field attributes using java API, so do you have an idea about this. i went through the insight API but there is not a proper example and giving a dependency error.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Pepe
After adding the condition still on another issue type like epic, story showing an error in web panel.
Is the placement of the condition in the web panel is important?
atlassian-plugin.xml
<web-panel name="Email" i18n-name-key="email.name" key="email" location="atl.jira.view.issue.right.context" weight="50">
<description key="email.description">The Email Plugin</description>
<context-provider class="xxxx.plugins.SendEmail"/>
<resource name="view" type="velocity" location="templates/email-indicator.vm"/>
<label key="Send-Email"/>
<condition class = "xxxx.plugins.ViewWebPanel"></condition>
</web-panel>
viewwebpanel class
public boolean shouldDisplay(ApplicationUser applicationUser, JiraHelper jiraHelper) {
Issue jiraIssue = (Issue) jiraHelper.getContextParams().get("issue");
Collection<ProjectComponent> components = jiraIssue.getComponents();
boolean compName = components.iterator().next().getName().equalsIgnoreCase("Jira");
String type = "IT Help";
if(compName == true && currentProject.getIssueTypes().iterator().next().equals(type));
return true;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What exception is thrown? Where I'm trying to use the JiraHelper it is set to null. You seem to be using it in the issue view and it should be defined so you will have some other exception. Your web panel configuration has tags in the same order that mine does and the order should not matter.
WRT Insight - you should talk directly to the vendor. You won't be able to access much Insight data via the Jira API and will need to use the Insight API directly. They will have the right answer for you. With another top app vendor I needed to get pom files from them to setup my build tools. Insight may have a similar requirement.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Pepe ,
Thanks for the response.
in my plugin, I am fetching the current issue request participants and putting it into the context map.
If the current issue request participants are not there then its showing web panel with an error like contact jira admin.
In this case, how i can handle this if the current issue does not have the request participant? then also it should not show the error but it proceeds without error.
Even I tried to put a context map with null in the else block if the request participant is not there but still showing the same error.
Regarding Insight i have raised a request with vendor.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
See what error you get in the Jira logs. It sounds like you're getting a 500 or other error from Jira. You should be able to determine if there are no participants on the issue in your condition and show/hide the panel. Or you can put an empty list in your context so that the panel renders but no participants are listed.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
HI @Pepe
Thank you for your continuous response.
The request participant error has been handled.
Actually I am adding some new functionality into it...like if XYZ custom field does not have field values then it should show a message stating that XYZ field does not contain a value.
For this, I am checking whether the XYZ field contains values or not in java class. if not, then putting string value (for indication) to context map and in .vm file checking the same and tried to show a message to the same panel but it's not working.
How do I handle this?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
is it possible to do something similar as @Pepe suggested (use a custom condition class that extends AbstractWebCondition) on Jira Cloud?
I've found that there are some predefined conditions but I'm interested in creating a custom condition
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.