From acafba42534fa16ed7adc0311c754965cfa085f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felix=20M=C3=BCller?= Date: Fri, 31 May 2024 17:15:05 +0200 Subject: [PATCH] fix(geomappanel.tsx): fix handling of relative/absolute paths to other dashboards Providing relative or absolute paths to other dashboards of the same grafana instance is now handled correctly. --- src/GeomapPanel.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/GeomapPanel.tsx b/src/GeomapPanel.tsx index ecb2c33..006586b 100644 --- a/src/GeomapPanel.tsx +++ b/src/GeomapPanel.tsx @@ -180,7 +180,7 @@ export class GeomapPanel extends Component { try { url = new URL(urlString); } catch (error) { - url = new URL(urlString, location.origin ) + url = new URL(urlString, location.origin); } let updateVars: Record = {}; @@ -194,15 +194,21 @@ export class GeomapPanel extends Component { "127.0.0.1" ] - if ((location.origin === url.origin || (localhostAliases.includes(url.hostname) && localhostAliases.includes(location.hostname) && url.port === location.port)) && + if ((location.origin === url.origin || + (localhostAliases.includes(url.hostname) && localhostAliases.includes(location.hostname) && url.port === location.port)) && (this.props.fieldConfig.defaults.links![0].targetBlank === undefined || this.props.fieldConfig.defaults.links![0].targetBlank === false)) { - // Update url with query parameters - locationService.partial({ ...updateVars }, true); + if(location.pathname === url.pathname) { + // Update url with query parameters + locationService.partial({ ...updateVars }, true); + } else { + locationService.push(url.pathname + url.search); + } } else { if (this.props.fieldConfig.defaults.links![0].targetBlank === undefined || this.props.fieldConfig.defaults.links![0].targetBlank === false) { - location.replace(url); + // location.assign(url); + location.assign(url); } else { open(url, "_blank"); }