* Skip intercepting links of different orgs
* Check if orgId is present on query params
* Use locationSearchToObject instead of parseKeyValue
* Revert locationSearchToObject to parseKeyValue
(cherry picked from commit 2a12644778)
Co-authored-by: Guilherme Caulada <guilherme.caulada@grafana.com>
This commit is contained in:
co-authored by
Guilherme Caulada
parent
39c4ba5e67
commit
d86fc082fb
@@ -1,5 +1,6 @@
|
|||||||
import { locationUtil } from '@grafana/data';
|
import { locationUtil, urlUtil } from '@grafana/data';
|
||||||
import { locationService, navigationLogger } from '@grafana/runtime';
|
import { locationService, navigationLogger } from '@grafana/runtime';
|
||||||
|
import { config } from 'app/core/config';
|
||||||
|
|
||||||
export function interceptLinkClicks(e: MouseEvent) {
|
export function interceptLinkClicks(e: MouseEvent) {
|
||||||
const anchor = getParentAnchor(e.target as HTMLElement);
|
const anchor = getParentAnchor(e.target as HTMLElement);
|
||||||
@@ -14,6 +15,8 @@ export function interceptLinkClicks(e: MouseEvent) {
|
|||||||
const target = anchor.getAttribute('target');
|
const target = anchor.getAttribute('target');
|
||||||
|
|
||||||
if (href && !target) {
|
if (href && !target) {
|
||||||
|
const params = urlUtil.parseKeyValue(href.split('?')[1]);
|
||||||
|
const orgIdChange = params.orgId && Number(params.orgId) !== config.bootData.user.orgId;
|
||||||
navigationLogger('utils', false, 'intercepting link click', e);
|
navigationLogger('utils', false, 'intercepting link click', e);
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
@@ -22,9 +25,9 @@ export function interceptLinkClicks(e: MouseEvent) {
|
|||||||
// Ensure old angular urls with no starting '/' are handled the same as before
|
// Ensure old angular urls with no starting '/' are handled the same as before
|
||||||
// Make sure external links are handled correctly
|
// Make sure external links are handled correctly
|
||||||
// That is they where seen as being absolute from app root
|
// That is they where seen as being absolute from app root
|
||||||
if (href[0] !== '/') {
|
if (href[0] !== '/' || orgIdChange) {
|
||||||
// if still contains protocol or is a mailto link, it's an absolute link to another domain or web application
|
// if still contains protocol or is a mailto link, it's an absolute link to another domain or web application
|
||||||
if (href.indexOf('://') > 0 || href.indexOf('mailto:') === 0) {
|
if (href.indexOf('://') > 0 || href.indexOf('mailto:') === 0 || orgIdChange) {
|
||||||
window.location.href = href;
|
window.location.href = href;
|
||||||
return;
|
return;
|
||||||
} else if (href.indexOf('#') === 0) {
|
} else if (href.indexOf('#') === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user