Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Limit plugin web-item visibility in project tab panel Edited

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.

1 answer

1 accepted

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;
    }
}

 

Hi Александр Верзаков,

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!

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Asked in Jira Service Management

JSM June ask me anything (AMA)

Hello Community members! We’re wrapping up the end of JSM June with an Ask Me Anything (AMA) with the Jira Service Management product team. This is your chance to ask all your ITSM questions to o...

255 views 12 14
View question

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you