Page decorator value for project settings page in JIRA

Hi, Atlassian!

are there idea on this?

I got it how to use my servlet on project admin. Below my code:
atlassian-plugin.xml

<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"/>
    <link linkId="fields-item-link">/plugins/servlet/project-config/$projectKeyEncoded/administer-fields</link>
    <!--<link linkId="fields-item-link">/secure/ActionsAction.jspa</link>-->
    <tooltip>Configure the Project Jira Plugin</tooltip>
  </web-item>
  <servlet name="FI" i18n-name-key="fi.name" key="fi" class="FServlet.FI">
    <description key="fi.description">The FI Plugin</description>
    <url-pattern>/project-config/*/administer-fields</url-pattern>
  </servlet>

success.vm

<!DOCTYPE HTML>
<html>
    <head>
    <title>Project - porject - FieldsItem</title>
        <meta name="decorator" content="admin"/>
        <meta name="projectKey" content="$project.key"/>
        <meta name="projectId" content="$project.id"/>
        <meta name="admin.active.tab" content="fields-item"/>
        <meta name="admin.active.section" content="atl.jira.proj.config"/>
    </head>
$webResourceManager.requireResources("com.atlassian.tutorial.DBFrame:DBFrame-resources")
    <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>

FI.java

package FServlet;

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

import javax.servlet.*;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.HashSet;
import java.util.Map;

import com.atlassian.templaterenderer.TemplateRenderer;

public class FI extends HttpServlet{
    private static final Logger log = LoggerFactory.getLogger(FI.class);

    private final TemplateRenderer renderer;

    public FI (TemplateRenderer renderer)
    {
        this.renderer = renderer;
    }

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
    {
        resp.setContentType("text/html;charset=utf-8");
        renderer.render("/templates/actions/success.vm", resp.getWriter());
    }
}

But after I click on item I get


I guess because I don’t get project key. Could you help me please?

Having the same problem. I too wish to add a custom section to the Project settings page. I have managed to get the link working but the rendered velocity template shows an Administration header rather than the Project settings header and no sidebar. Has anyone managed to get this to work?

Cheers

Added:

#set($projectId = $versionObj.projectId)
#set($projectKey = $versionObj.projectKey)

In the velocity template and it worked

If you need the ProjectKey in your controller, you can do something like this:

String projectKey = request.getRequestURI().substring(0,request.getRequestURI().lastIndexOf("/"));
projectKey = projectKey.substring(projectKey.lastIndexOf("/")+1);
Project currentProject = projectManager.getProjectByCurrentKey(projectKey);

Have you solved the problem of ’ plugins/servlet/project-config/PRJ/screens – project tab ‘’ does not exist’?
Can you tell me the solution? :thinking:

If you want to show the project navigation, use a web-panel instead of a servlet.

<web-item key="my-item" name="my-item" section="jira.project.sidebar.plugins.navigation" weight="1000">
    <label key="myitem.label"/>
    <link linkId="my-item-link">/projects/${pathEncodedProjectKey}?selectedItem=my-item</link>
    <condition class="xx.MyItemCondition"/>
</web-item>

<web-panel name="My Item Page" key="my-item-page" location="my-item" weight="1000">
    <context-provider class="xx.MyItemContextProvider"/>
    <resource name="view" type="velocity" location="templates/my-item.vm"/>
    <condition class="xx.MyItemCondition"/>
</web-panel>

MyItemContextProvider implements ContextProvider and MyItemCondition implements Condition

The selectedItem in web-item must match the location in web-panel.

You don’t have do define any meta or decorator tags in the .vm file.

see https://developer.atlassian.com/server/jira/platform/developing-for-the-jira-project-centric-view/#basic-implementation

After upgrading jira server version to 9.7.0 my project setting page suddenly stopped working as it contains the hash in url. The hash router used for our application is not working for jira 9.7.0 version. It is working fine for other jira versions.

atlassian-plugin.xml

<web-section key="project-configuration-section" location="atl.jira.proj.config" weight="300">
</web-section>
<web-item key="project-configuration-item" section="atl.jira.proj.config/project-configuration-section">
        <label key="project.section.title"/>
        <link linkId="configuration_area">/secure/TestManagementProjectSettings.jspa?projectKey=$project.key#/project-settings</link>
    </web-item>

success.vm

<!DOCTYPE html>
<html>
  <head>
    <title>Project Settings</title>
    <meta name="decorator" content="atl.admin" />
    <meta name="projectId" content="10200" />
    <meta name="projectKey" content="SAN" />
    <meta name="admin.active.section" content="atl.jira.proj.config" />
    <meta name="admin.active.tab" content="test-project-settings" />
  </head>
  <body>
      <div>Test Hello</div>
  </body>
</html>

Previously it is showing like below -

After upgrading jira server version it is changing the main page URL and redirecting to Home page. Previously it is loading the content of vm file.

If i am removing the projectkey in vm file then it loads the content of vm file but not in a project setting section.

3 Likes

Hi @krishnashah. We are having the same issue, did you find a workaround for this?

@samdawson , for now we have removed hash from the url and added different condition for that particular component.

Thanks @krishnashah. I’ve created a support request with Atlassian, hopefully we can get this fixed soon.

1 Like

we are facing the same issue :frowning:

Hi any update on this issue?

Hi @samdawson ,

any update on your support request?

Thanks