Page decorator value for project settings page in JIRA

Hi,

My plugin adds a new tab under projectgroup4 of project settings page in JIRA. When I click the tab that is newly added, I render a velocity template which should also look like project settings page but with the panel on the right specific to my plugin.

I couldn’t find any decorators other than the standard ones mention here: Using standard page decorators

Where can I find all available page decorators? If not, I would like to the value for project settings page.

Right now, I have these meta lines in my velocity template:

<meta name="decorator" content="atl.general"/>
        <meta name="admin.active.section" content="atl.jira.proj.config/projectgroup4"/>
        <meta name="admin.active.tab" content="my-tab-name"/>
2 Likes

@david.pinn Thought you could help.

@daniel @jobinkk @justin_shapiro Guys can anyone help?

@ibuchanan is it okay to tag people like this for answers?

For JIRA the best source is to look is the source. I’ve tried to programatically extract it but you have to start heading into SiteMesh land and JIRA’s api didn’t expose it at the time. I’ll add it to my list to look at tomorrow.

But that said in JIRA’s source - take a look at jira-project/jira-components/jira-webapp-common/src/main/webapp/WEB-INF/decorator.xml - it will have a lot of the standard decorators that are available. Note the word standard… :frowning: In this case you want a bunch more data supplied.

In this case you want to look in jira-project/jira-components/jira-plugins/jira-project-config-plugin/src/main/resources/global/tab.vm:

    <meta name="decorator" content="admin"/>
    <meta name="projectKey" content="$project.key"/>
    <meta name="projectId" content="$project.id"/>
    <meta name="admin.active.tab" content="$linkId"/>
    <meta name="admin.active.section" content="atl.jira.proj.config"/>

Where $linkId is the linkId of your web-item.

2 Likes

Hey @daniel

I have tried your solution.

 <meta name="decorator" content="admin"/>
    <meta name="projectKey" content="$project.key"/>
    <meta name="projectId" content="$project.id"/>
    <meta name="admin.active.section" content="atl.jira.proj.config/projectgroup3"/>
    <meta name="admin.active.tab" content="link-projects"/>

It looks like this:

I want it to look like this:

I believe this is because the decorator here is given as “admin”. Any suggestions?
And thanks for the tip. I didn’t know we could access JIRA source. I will figure out how to access the code.

What’s your url for the page? One of my tabs I’ve got the web-item with:

/secure/MyAction!default.jspa?pid=${helper.projectObject.id}&amp;projectKey=$projectKeyEncoded
2 Likes

The source is available at https://my.atlassian.com - it’s available for any account that has bought a commercial license (including the $10 starter license).

1 Like

Its working now. My URL is : “http://localhost:2990/jira/secure/VersionSyncWebworkAction!default.jspa

However, I have the project key and project id hardcoded in the velocity file now and it worked.

But the project side bar is missing. See below pic:

How do I get the missing piece?
Also, I got access to the source code and was trying to make my way through it.

1 Like

It’s a young community, so you’re breaking new ground. :slight_smile: I think you do great honor to those you tag, showing that you value their input.

1 Like

My guess is that that comes in via javascript somehow. In JIRA’s source take a look at jira-project/jira-components/jira-plugins/jira-project-config-plugin/src/main/java/com/atlassian/jira/projectconfig/servlet/PanelServlet.java and compare with what you have.

Note: I think you’ll need JIRA 7.3’s source since the couple of JIRA versions I checked before that didn’t have the plugin’s source. :frowning:

Oe… a Version Sync competitor! :wave:
@kaushikveluru If you need any help with getting some grip on the inner workings of Version & Components in JIRA, make sure to ping me. I’ve been working with this since 2012 and there are some pitfalls I might be able to help you avoid!

@remie Thank you Remie. I have been off that project for a while now. Will get back working on it soon. Will reach out to you then.

1 Like

I have exactly the same issue, I figured out that what I was missing is the following meta-tag:

<meta name="projectKey" content="$project.key"/>

However, $project.key cannot be resolved. When I hard code the project key, everything works like a charm.

What do I need to do for $project.key to be properly resolved?

Hi Rens,

I think you’ll need to put the current project into the rendering context. The context provider for your panel might have something like this:

@Override
public Map<String, Object> getContextMap(Map<String, Object> context) {
    @Nullable Project project = (Project) context.get("project");
    if (project == null) {
        throw new NullPointerException("Project must not be null");
    }
    Map<String, Object> params = Maps.newHashMap();
    params.putAll(JiraVelocityUtils.getDefaultVelocityParams(context, jiraAuthenticationContext));
    params.put("project", project);
    return createVelocityParams(params);
}

If you are using IntelliJ IDEA, you might like to include the following line at the top of your Velocity template file; it lets IntelliJ know to expect “project” in the Velocity context, and will enable auto-complete for that variable.

#* @vtlvariable name="project" type="com.atlassian.jira.project.Project" *#

Hi David,

It was a different issue. My class is an extension of ProjectActionSupport. I have to access the project id and key by referencing the selectedProject property:

<meta name="projectId" content="$selectedProject.id"/>
<meta name="projectKey" content="$selectedProject.key"/>

Hi @kaushikveluru, I have the exact same issue. The sidebar is not displayed when I click on my plugin’s project settings link. Have you been able to solve this?

I was able to figure this out. You need to set all four of the following meta keys:

<meta name="decorator" content="admin."/>
<meta name="projectKey" content="$projectKey"/> <!-- ensure this is on view context server side via servlet and BrowseContext -->
<meta name="projectId" content="$projectId"/> <!-- ensure this is on view context server side via servlet and BrowseContext -->
<meta name="admin.active.section" content="alt.jira.proj.config"/>

How’d I figure this out? I viewed source in Google Chrome after clicking the Users and roles menu item in the project setting left navigation. You’ll see these meta keys inside the head section.

@daniel offered a working solution but nobody noticed the trap that @kaushikveluru stepped into. I made the same mistake and i just want to make this clear for people reading this in the future.

Have a look at this line:

<meta name="admin.active.section" content="atl.jira.proj.config/projectgroup4"/>

There is a false friend hiding in plane sight: “admin.active.section”. When you wrote this, you probably looked at your web-item, which should look something like this:

<web-item section="atl.jira.proj.config/projectgroup4" ...>
    ...
</web-item>

And thought to yourself “admin.active.section” should probably have the same value as the section attribute in your web-item. But that’s wrong! Once you append “/projectconfigX” or whatever your web-section is called to “atl.jira.proj.config” the sidebar won’t render anymore.

It’s quite easy to miss this subtlety and think “my decorators look exactly the same as in @daniel’s solution and it doesn’t work!” when they actually don’t. So i just wanted to make this clear. Only this will work:

<meta name="admin.active.section" content="atl.jira.proj.config"/>
3 Likes

Hi anyone!

Could you help me please to correct my Action? I try to add web-item:

<web-item name="FieldsItem" i18n-name-key="fields-item.name" key="fields-item" section="atl.jira.proj.config/projectgroup3" weight="1000">
    <description key="fields-item.description">The FieldsItem Plugin</description>
    <label key="fields-item.label"></label>
    <link linkId="fields-item-link">/secure/ActionsAction.jspa</link>
  </web-item>

tab.vm

<!DOCTYPE HTML>
<html>
    <head>
    <title>MyTestPage</title>
        <meta name="decorator" content="atl.admin"/>
        <meta name="projectKey" content="$project.getKey()"/>
        <meta name="projectId" content="$project.getId()"/>
        <meta name="admin.active.tab" content="fields-item-link"/>
        <meta name="admin.active.section" content="atl.jira.proj.config"/>
        $webResourceManager.requireResourcesForContext("my-resources")
    </head>
    <body>
        <div style = "text-align:center; padding: 2px;">
        <img src="$req.contextPath/download/resources/com.atlassian.tutorial.DBFrame:DBFrame-resources/images/picture.gif" alt="Picture">
        </div>
    </body>
</html>

Action.java

package com.atlassian.tutorial.jira.webwork;

import com.atlassian.jira.project.Project;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.atlassian.jira.web.action.JiraWebActionSupport;

public class ActionsAction extends JiraWebActionSupport
{
    private static final Logger log = LoggerFactory.getLogger(ActionsAction.class);
    private Project project;
    @Override
    public String execute() throws Exception {
        project = getSelectedProjectObject();
        //noinspection deprecation
        request.setAttribute("com.atlassian.jira.projectconfig.util.ServletRequestProjectConfigRequestCache:project", project);
        return super.execute(); //returns SUCCESS
    }
}

I get picture in jira admin menu, not a project menu

And I want to get a link such as screens:
https://1.1.1.1/plugins/servlet/project-config/PRJ/screens
But I have
https://1.1.1.1/secure/ActionsAction.jspa

resolved it

<meta name="projectKey" content="$selectedProject.key"/>
<meta name="projectId" content="$selectedProject.id"/>

Then remains to understand how to make the url correct(( When I try to get access to
https://1.1.1.1//plugins/servlet/project-config/PRJ/administer-fields, I get


How to link web-item with velocity template?