Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JIRA layout per-project

Tags:

jira

Would it be possible to use a project-specific stylesheet for JIRA projects?

For example, if I would like to include project X in an iframe, I'd like to hide the logo and possibly the JIRA toolbar - for specific user groups for example (it's only for viewing purpose, it is not a security feature)

Granted that I'd have to implement this myself (through the webservice api for example) - are there templates for the standard issue page?

Thanks in advance!

like image 625
Stefan Ernst Avatar asked Dec 16 '22 16:12

Stefan Ernst


2 Answers

There is a (currently undocumented) plugin point in JIRA for inserting top navigation components, <top-navigation>.

You can use this plugin point to add your own navigation bar, and perhaps hide the normal bar using an inline CSS stylesheet. The following example triggers this behavior by using a ?hideit=true query parameter, which is the simplest way to approach the "embed in iframe" problem. You could make that "sticky" by storing it in a session or cookie.

Once you have created a plugin that plugins into the <top-navigation>, hiding the top bar is simple. Here is a velocity script that does it:

#if ($hideHeaderHack)
    <style>
        \#header {display:none;}
    </style>
    HIDDEN (remove this message eventually)
#else
    NORMAL (remove this message eventually)
#end

To create such a plugin, use the Atlassian Plugin SDK (use atlas-create-jira-plugin). Your atlassian-plugin.xml should look like:

<atlassian-plugin key="${project.groupId}.${project.artifactId}" name="${project.name}" plugins-version="2">
    <plugin-info>
        <description>${project.description}</description>
        <version>${project.version}</version>
        <vendor name="${project.organization.name}" url="${project.organization.url}" />
    </plugin-info>

    <top-navigation key="standard-navigation-top"
                    name="Tigerblood"
                    class="com.madbean.topnavhack.TopNav" state='enabled'>
        <resource type="velocity" name="view" location="topnav.vm"/>
        <order>5</order>
    </top-navigation>

</atlassian-plugin>

Your top-navigation implementation class (called com.madbean.topnavhack.TopNav above) should look like:

public class TopNav implements PluggableTopNavigation {
    private TopNavigationModuleDescriptor descriptor;

    public void init(TopNavigationModuleDescriptor descriptor)
    {
        this.descriptor = descriptor;
    }

    public String getHtml(HttpServletRequest request) {
        Map<String,Object> params = new HashMap<String, Object>();

        params.put("hideHeaderHack", "true".equals(request.getParameter("hideit")));

        return descriptor.getTopNavigationHtml(request, params);
    }
}

Your plugin will be laid out something like:

./pom.xml
./src/main/java/com/madbean/topnavhack/TopNav.java
./src/main/resources/atlassian-plugin.xml
./src/main/resources/topnav.vm

Disclaimer I work for Atlassian as a developer in the JIRA team.

like image 115
Matt Quail Avatar answered Mar 05 '23 08:03

Matt Quail


I don't believe this functionality is exposed directly, and you don't state what JIRA version you are using, but in 4.x in \atlassian-jira\includes\decorators there is a file called bodytop.jsp the has the following fragment that renders the top level navigation and toolbar elements:

// Render all the top nav plugins for (Iterator iterator = topNavPlugins.iterator(); iterator.hasNext();) { TopNavigationModuleDescriptor topNavModuleDescriptor = (TopNavigationModuleDescriptor) iterator.next(); PluggableTopNavigation pluggableTopNavigation = (PluggableTopNavigation) topNavModuleDescriptor.getModule();

%> <%= pluggableTopNavigation.getHtml(request) %> <% } %>

If you wanted to you could create a version of the dashboard rendering jsp that calls a modified bodytop.jsp that renders none of the usual nav elements.

like image 26
Amasuriel Avatar answered Mar 05 '23 07:03

Amasuriel