Hi colleagues.
I have webwork with web-item that inserted in project tab panel. How can i restrict this web-item appereance in project tab panel for target project?
Thanks in advice.
Solution is in using conditions setting of web-item. And impelement Condition class.
public class ConditionCheck implements Condition { private static final Logger log = Logger.getLogger(ConditionCheck.class); private SettingsStorageService settingsStorageService; private String projectId; public ConditionCheck(PluginSettingsFactory pluginSettingsFactory) { this.settingsStorageService = new SettingsStorageService(pluginSettingsFactory); } @Override public void init(Map<String, String> map) throws PluginParseException { } @Override public boolean shouldDisplay(Map context) { final JiraHelper jiraHelper = (JiraHelper)context.get(JiraWebInterfaceManager.CONTEXT_KEY_HELPER); List<Project> projects = Utils.getInquirerProjects(settingsStorageService, "key"); String state = settingsStorageService.getSetting("enebled"); if(state.equals("Disabled")) { return true; } if(state.equals("Enabled(All projects)")) { return false; } try { String projectId = jiraHelper.getProject().getId().toString(); for(Project project: projects) { if(project.getProjectId().equals(projectId)) { return !project.isSelected(); } } } catch (Exception e) { return true; } return true; } }
Could you elaborate the solution. I am kind of new to Jira development, so, any help would be appreciated.
PFA my code snippet for atlassian-plugin.xml
<project-blueprint key="my-project-template" weight="90">
<label key="my.project.template.name"/>
<projectTypeKey>business</projectTypeKey>
<!--<projectTypeKey>software</projectTypeKey>-->
<description key="my.project.template.description"/>
<longDescription key="my.project.template.description.long"/>
<infoPage soy-template="JIRA.Templates.ProjectTemplates.Tutorial.renderMyProjectTemplateExplanation"/>
<icon location="images/icon.jpg"/>
<backgroundIcon location="images/background.jpg"/>
<add-project>
<hook class="com.example.plugins.tutorial.MyAddProjectHook"/>
<descriptor file="/config/my-project-template-config.json"/>
</add-project>
</project-blueprint>
<web-item name="project-web-item" i18n-name-key="project--web--item.name" key="project--web--item"
section="jira.project.sidebar.plugins.navigation" weight="300">
<description key="project--web--item.description">The project-web-item Plugin</description>
<label key="project--web--item.label"/>
<!--This web item links to a servlet-->
<link linkId="project--web--item-link">/plugins/servlet/issuecrud</link>
<param name="iconClass" value="aui-icon-large icon-sidebar-release"/>
</web-item>
I want the web-item above to be displayed only when someone creates a project using my custom project blueprint only.
---------------------------
Also, PFA my code for MyAddProjectHook.java for the custom project template/blueprint.
package com.example.plugins.tutorial;
import com.atlassian.jira.project.template.hook.AddProjectHook;
import com.atlassian.jira.project.template.hook.ValidateData;
import com.atlassian.jira.project.template.hook.ValidateResponse;
import com.atlassian.jira.project.template.hook.ConfigureData;
import com.atlassian.jira.project.template.hook.ConfigureResponse;
public class MyAddProjectHook implements AddProjectHook
{
@Override
public ValidateResponse validate(final ValidateData validateData) {
ValidateResponse validateResponse = ValidateResponse.create();
//projectKey
if (validateData.projectName().equals("TEST")) {
validateResponse.addErrorMessage("Invalid Project Name");
}
return validateResponse;
}
@Override
public ConfigureResponse configure(final ConfigureData configureData)
{
return ConfigureResponse.create();
}
}
Regards and thanks in advance!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.