Renuka Renuka - 23 days ago 6
Javascript Question

How to hide some issue link types in the Issue Link pop up window for Jira 5.1.8 using javascript?

I wanted to hide some issue link outward & inwards strings of Link type from the Link Issues Popup Window using java script.

I have tried using java script but I am not getting the popup screen from the java script.

Please see the screenshot below :

Hide Issue Link types

Can anyone tell me how can I get this popup screen in the java script?
Is there any other method to hide this?

Thanks & Regards,

Renuka.

Kuf Kuf
Answer

To hide the clone issue link every page:

edit the file system-webresources-plugin.xml (should be at /atlassian-jira/WEB-INF/classes/), and add to <web-resource key="jira-fields"> this code:

    <resource type="download" name="myScript.js" location="/includes/jira/field/script.js">
        <param name="source" value="webContextStatic"/>
    </resource>

than, on /includes/jira/field/myScript.js write this:

AJS.$(document).ready(function() {
    if (AJS.$("#link-type option[value*='clon']").size() > 0) {
        // will work even when right clicking on More 
        // Actions->Link & open it into a new window
        AJS.$("#link-type option[value*='clon']").remove()
    } else if (AJS.$("#link-issue").size() > 0) {
        // will work in case the link menu showing via popup
        AJS.$("#link-issue").click(function(){
            // wait for the popup to show, and remove the clone options
            setTimeout(function (){
                AJS.$("#link-type option[value*='clon']").remove();
             }, 300);
        });
    }
});

restart Jira and it that it!

The script attaches a function to the link-menu opening, than gives the menu 0.3 seconds to load, and removes the unwanted items. If it doesn't work well for you, try to raise the timeout from 300 to 500-1000.

On jira 4, run instead:

    AJS.$("#issue-link-link-type option[value*='clon']").remove();