Skip to content

Commit

Permalink
fix(geomappanel.tsx): fix handling of relative/absolute paths to othe…
Browse files Browse the repository at this point in the history
…r dashboards

Providing relative or absolute paths to other dashboards of the same grafana instance is now handled
correctly.
  • Loading branch information
felix-mu committed May 31, 2024
1 parent b55ee89 commit acafba4
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/GeomapPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ export class GeomapPanel extends Component<Props, State> {
try {
url = new URL(urlString);
} catch (error) {
url = new URL(urlString, location.origin )
url = new URL(urlString, location.origin);
}

let updateVars: Record<string, string> = {};
Expand All @@ -194,15 +194,21 @@ export class GeomapPanel extends Component<Props, State> {
"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");
}
Expand Down

0 comments on commit acafba4

Please sign in to comment.