Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to limit visibility of web item to just our project template/blueprint plugin in JIRA Server?

Dhruv Dixit February 24, 2019

I have created a plugin having a project blueprint/template and a web item.

Now, I want the web item to be only visible when someone creates a project using my custom project blueprint/template only i.e. the web item should not be visible when any project is created using any other predefined or existing project templates.

How can I embed the web item to only my project template/blueprint?

1 answer

0 votes
Mohamed Adel
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.
February 24, 2019

Try this Solution 

Dhruv Dixit February 24, 2019

Hi Mohamed,

Could you elaborate the solution in the link provided by you. 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 only visible when someone creates a project using my 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!

Dhruv Dixit February 24, 2019

Any help would be appreciated.

Suggest an answer

Log in or Sign up to answer