Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Java script in issue navigator

Shun Hirayanagi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

Hello,

I'm developing a JIRA plugin which consists of a java script.
The script shows up in issue view screen and changes the look and feel of issue view screen.

It works fine when I open a single issue (such as /browse/ISSUE-1).
However, it doesn't work in issue navigator with "Detail view".
I want this script to work for an issue displayed in the right pane of the issue navigator.

How can I achieve this?

I'm using JIRA version 6.4.2 and here are my code snippets.

<web-resource key="my-plugin-resources" name="my-plugin Web Resources">
    <dependency>com.atlassian.auiplugin:ajs</dependency>
    <resource type="download" name="my-plugin.js" location="/js/my-plugin.js"/>
    <context>jira.view.issue</context>
</web-resource>
AJS.$(document).ready(function () {
// my code here

console.log("my-plugin.js")
// This code is called when issue navigator is opened.
// However, it is not called again even if I chose another issue in the issue navigator.

});

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

3 votes
Answer accepted
Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

Hi Shun!

In your <web-resource> tag you need to add navigator contexts to load your script on the issue navigator page:

&lt;context&gt;jira.navigator.advanced&lt;/context&gt;
    &lt;context&gt;jira.navigator.simple&lt;/context&gt;

==== update:

You need to put your code inside of the JIRA event listener:

JIRA.bind(JIRA.Events.NEW_CONTENT_ADDED, function (e, context, reason) {
        if (reason !== JIRA.CONTENT_ADDED_REASON.panelRefreshed) {
            // You code here
        }
    });

You can search for "NEW_CONTENT_ADDED" in chrome dev tools while you are on the navigator page and will find that JIRA uses this event for invoking scripts after the new issue is loaded. Just debugged this and strange thing is that it's invoked 2 times, but anyway this is how it's done in JIRA.

 

Shun Hirayanagi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

Hi Volodymyr, Thank you for your comment! <context>jira.view.issue</context> seems to work in the issue navigator page as well. My code is called when the issue navigator is opened without jira.navigator context. The problem is that my code is not called again when I chose another issue in the issue navigator.

Volodymyr Krupach
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 28, 2015

Shun, please see edited initial response.

Shun Hirayanagi
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 29, 2015

Hi Volodymyr, You code worked! I really appreciate your kind support.

Prashant Mali September 26, 2016

Hi Volodymyr

Your code working fine. thank you so much

 

TAGS
AUG Leaders

Atlassian Community Events