Link to a generalPage, open in new tab?

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?

1 Like

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.

2 Likes

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.

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.

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

1 Like

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.

3 Likes

I too ended up with same solution,

for Jira this is fine
for Confluence we need to append /wiki (context path)

and do you know if the context path is customizable ?

Just wanted to say thanks for the workarounds. :+1: Too bad we cannot do sth like

AP.navigator.go("projectAdminTabPanel",
      {
        addonKey: environment.addonKey,
        adminPageKey: myPageKey,
        projectKey: context.jira.project.key,
        projectId: context.jira.project.id,

        **target: '_blank'**

});
3 Likes