I tested it with Custom UI and the react-router stuff, works awesome
The only thing I really would like to do is support “Open link in new Tab”. Meaning: The a-href should contain the full URL with https://mysite.atlassian.net/...
BUT: Even though I manage to build the jira:projectPage base URI the opened URL is the CDN baseURL e.g. https://atlassian-cdn.foo123.atlassian.net/...
So the code snippet is not quite right, because it states this:
<a
href={to} /// <---- DOES NOT WORK
onClick={(event) => {
event.preventDefault();
history.push(to);
}}
Question: Is there any way to get the site baseURL in a forge resolver?
I mean https://[SITE].atlassian.net/.
Because when using full baseURL in a-href a normal click would still route with onclick but a middle-mouse click would (for most users) open a new tab with the full URL correctly.
In the router.navigate and router.open APIs, a relative URL will be prefixed with the site URL, e.g. router.navigate('/browse') will navigate to https://[SITE].atlassian.net/browse
Thanks for your fast answer I know this works that way, but it is still a JS-only triggered thing. This does not solve the “Open link in new tab” problem, that would only work with the a-href and native browser support without JS.
Maybe you can elaborate if this can work in the future.
What would be great would be some method like “router.getBaseUrl()” which returns https://[SITE].atlassian.net
UPDATE: Since the Custom UI is inside an iframe we can do it via document.location.ancestorOrigins
<a
href={`${document.location.ancestorOrigins[0]}${to}`} /// <---- DOES WORK and prepends SITE.atlassian.net
onClick={(event) => {
event.preventDefault();
history.push(to);
}}