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

Webitem - how to parameter a link which opens the target link in another tab / window

francis
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 27, 2011

Hi,

We need to add a link in the operation bar of a JIRA issue. This is straightforward as documented
http://confluence.atlassian.com/display/JIRADEV/Web+Item+Plugin+Module

and it works :-)

Now, we would like to open up a new page (either as a new window, or as a new tab) when the user clicks the operation.
I've been searching the documentation, but I didn't see any good reference / example.

Any clues ?

Francis

3 answers

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Deepali Bagul March 29, 2018

Hi,

I know this is the old post, but the solution may help others.

I came up with the alternate solution. We have installed Php on jira server instance (v7.5.1). I created a html page under jira_extend and specified that url of the page in the plugin this allows to me open the webitem link in new tab. Below is the code for html page

<html>
<head>
<script>
function loadInTab() {
url = "http://google.com";
window.open(url,'_blank');
history.back();
}
</script>
</head>
<body onload="loadInTab()"></body>
</html>

Make a HTML page with that - save it under /var/www/html/jira_extend/

lets say we called it openlink.php

so link in the webitem part definition would be http://jira.server/jira_extend/openlink.php

Hope this helps

0 votes
Wojciech Seliga
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.
August 28, 2011

Hi,

After taking a deeper look at the source code responsible for handling web items and building UI from that, I think that the documentation which Alexander references above uses unfortunate example which suggests that JIRA actually handles something called isPopupLink.

However in the source (viewissue-opsbar.jsp, com.atlassian.jira.plugin.webfragment.DefaultSimpleLinkManager) I see no reference whatsoever to such params. Moreover JIRA of of the box uses at leaast one web-item which opens a separate window - the one used for attaching screenshots (tiny applet allowing to paste images from clipboard). This single piece of functionality does not use isPopupLink either. Actually it has no params defined in XML, but instead uses extra javascript hacking (see ViewIssue.js) which overwrites standard <a> behaviour:

var openInNewWindow = function(e)

{

e.preventDefault();

e.stopPropagation();

var $this = jQuery(this);

// close the link

jQuery(document).click();

new JIRA.ScreenshotDialog({

trigger: $this

}).openWindow();

};

...

AJS.$("#attach-screenshot").click(openInNewWindow);

I have used exactly the same approach for years in my plugin (just inject your custom javascript file with WebResourceManager.requireResource and then perform run-time DOM manipulation (the easiest with JQuery).
You can find example how to do such js injection here, but with newest versions of JIRA you should be able to use Web Resource Context jira.view.issue.
Hope it helps.
Cheers,
Wojtek

francis
Marketplace Partner
Marketplace Partners provide apps and integrations available on the Atlassian Marketplace that extend the power of Atlassian products.
August 28, 2011

I will certainly give it a go.

Thanks for the details.

0 votes
Alexander Johannes
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.
August 28, 2011

The closest i can see from the documentation is something like <param name="isPopupLink" value="true" />.

Normally you would force opening in a new window via <a href="#" target="_blank">. But i don't see, how to supply this to a web item.

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

TAGS
AUG Leaders

Atlassian Community Events