Link to a generalPage, open in new tab?

navigation
javascript

#1

I currently have a webPanel in the issue view (atl.jira.view.issue.right.context) with a link in it to a generalPage. I can use the javascript API to link to that generalPage: AP.navigator.go()

Is there a way to make that link open a new tab?


#2

Depending on how you display the link, you might try to construct it on your own and create standard <a href="" target="_blank"> link.

As far as I know, the AP.navigator.go() does not allow to open anything in new window/tab but I’m curious if Atlassian can confirm that.


#3

Ah, great idea. Do you know what the best way would be to get the outer domain name (customer.atlassian.net) from within the addon iframe? I tried with relative URLs but that opens a new tab with my addon domain.


#4

If you use standard Atlassian stack, then {{hostBaseUrl}} is available in hbs files, which can next be added to your page/iframe meta through <meta name="hostBaseUrl" content="{{hostBaseUrl}}"> and retrieved in app JavaScript.


#5

Using javascript API solely, I do it with AP.getLocation() and regular expression to extract hostBaseUrl. May be there is better way though.


#6

Thanks, I ended up using a combination of both of your advice. Had to use AP.getLocation because I’m not using the standard Atlassian stack:

First get the origin (https://blah.atlassian.net)

window.AP.getLocation(location => {
          const url = new URL(location)
          this.baseUrl = url.origin})

Then use that to generate the full URL:

getNewTabLink (requirement) {
        return `${this.baseUrl}/plugins/servlet/ac/my-addon-name/my-addon-name`
},

Finally, used target="_blank" in the a tag, using the URL generated in the previous function.