Add a new page to JIRA Service Desk

I am developing a plugin for JIRA and JIRA Service Desk. So far I have created a Web-Item on the Customers portal but I want to redirect to a new section to show a dashboard to the users.

I have seen JIRA Service Desk UI plugin points that show the available places to insert a new section or web item but what I would really like to have is to keep the Header and footer only and be able to customize the central area.

Below is the image of the Portal where I would like to have a new page and using webworks I managed to create a new page but it does not keep the header neither the footer. I have tried changing the link of the web item but this is the only result I got

So far this is what I was able to do:

1 Like

Hello,
I’m too trying to add a custom portal page, i used the Action class AddPortalPage but i can’t figure out the url to .jspa that will redirect the user to .vm file via the webwork module.

As far as i know, it’s not possible to add a new page via servlets or webwork modules and keep the JSD context, such as the toolbar on the top, because JSD is a single page application. A colleague and I asked a bunch of Atlassian developers at the atlas camp in Vienna 2019 about this specific question, and none of them knew of a way to do it.

You can only add new pages via a servlet (But they will miss the help center toolbar on the top).

In atlassian-plugin.xml example:

<servlet name="Customer Servlet" i18n-name-key="customer-servlet.name" key="customer-servlet" class="io.aety.servlet.customer.MyCustomerServlet">
    <description key="customer-servlet.description">A Servlet for Customers</description>
    <url-pattern>/customerservlet</url-pattern>
</servlet>

<!-- Don't forget to add a customer context, to your servlet path, otherwise non-jira users will be denied permission to access these servlets-->
<customercontext key="customerservletcontext" path="/plugins/servlet/customerservlet">
    <uri regex=".*"/>
</customercontext>

And a basic servlet:

@Scanned
public class MyCustomerServlet extends HttpServlet {

    @ComponentImport
    private final LoginUriProvider loginUriProvider;
    @ComponentImport
    private final TemplateRenderer templateRenderer;

    private static final Logger log = Logger.getLogger(MyCustomerServlet.class);

    @Inject
    public MyCustomerServlet(LoginUriProvider loginUriProvider,
                           TemplateRenderer templateRenderer) {
        this.loginUriProvider = loginUriProvider;
        this.templateRenderer = templateRenderer;
    }

    @Override
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser();
        if (user == null) {
            redirectToLogin(request, response);
            return;
        }

        //Supply the template renderer with a velocity template, and a context map with variables needed in the vm template
        Map<String, Object> context = new HashMap<>();
		context.put("myVmVariable", 100);

        templateRenderer.render("velocity/myVelocityTemplate.vm", context, response.getWriter());
    }
	
	private void redirectToLogin(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.sendRedirect(loginUriProvider.getLoginUri(getUri(request)).toASCIIString());
        log.debug("Redirected");
    }

    private URI getUri(HttpServletRequest request) {
        StringBuffer builder = request.getRequestURL();
        if (request.getQueryString() != null) {
            builder.append("?");
            builder.append(request.getQueryString());
        }
        return URI.create(builder.toString());
    }
}