From 7c9ac0f990f3a92dec2da5600a465b23771e3923 Mon Sep 17 00:00:00 2001 From: Jack Westbrook Date: Mon, 17 May 2021 09:31:48 +0200 Subject: [PATCH] Annotations panel: Remove subpath from dashboard links (#34134) * fix(annolistpanel): strip base from url to prevent subpath duplication * fix(centrifuge): allow connections when served from subpath --- public/app/features/live/live.ts | 2 +- .../app/plugins/panel/annolist/AnnoListPanel.tsx | 15 +++++---------- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/public/app/features/live/live.ts b/public/app/features/live/live.ts index a41dd10afb9..d3f44e616de 100644 --- a/public/app/features/live/live.ts +++ b/public/app/features/live/live.ts @@ -55,7 +55,7 @@ export class CentrifugeSrv implements GrafanaLiveSrv { constructor() { const baseURL = window.location.origin.replace('http', 'ws'); - const liveUrl = `${baseURL}/${config.appSubUrl}api/live/ws`; + const liveUrl = `${baseURL}${config.appSubUrl}/api/live/ws`; this.orgId = (window as any).grafanaBootData.user.orgId; this.centrifuge = new Centrifuge(liveUrl, { debug: true, diff --git a/public/app/plugins/panel/annolist/AnnoListPanel.tsx b/public/app/plugins/panel/annolist/AnnoListPanel.tsx index 1c5df2bbbf9..0deef387034 100644 --- a/public/app/plugins/panel/annolist/AnnoListPanel.tsx +++ b/public/app/plugins/panel/annolist/AnnoListPanel.tsx @@ -2,8 +2,8 @@ import React, { PureComponent } from 'react'; // Types import { AnnoOptions } from './types'; -import { AnnotationEvent, AppEvents, dateTime, DurationUnit, PanelProps } from '@grafana/data'; -import { getBackendSrv, getLocationSrv } from '@grafana/runtime'; +import { AnnotationEvent, AppEvents, dateTime, DurationUnit, locationUtil, PanelProps } from '@grafana/data'; +import { getBackendSrv, locationService } from '@grafana/runtime'; import { AbstractList } from '@grafana/ui/src/components/List/AbstractList'; import { getDashboardSrv } from 'app/features/dashboard/services/DashboardSrv'; import appEvents from 'app/core/app_events'; @@ -121,10 +121,7 @@ export class AnnoListPanel extends PureComponent { } if (current?.id === anno.dashboardId) { - getLocationSrv().update({ - query: params, - partial: true, - }); + locationService.partial(params); return; } @@ -133,10 +130,8 @@ export class AnnoListPanel extends PureComponent { .then((res: any[]) => { if (res && res.length && res[0].id === anno.dashboardId) { const dash = res[0]; - getLocationSrv().update({ - query: params, - path: dash.url, - }); + const newUrl = locationUtil.stripBaseFromUrl(dash.url); + locationService.push(newUrl); return; } appEvents.emit(AppEvents.alertWarning, ['Unknown Dashboard: ' + anno.dashboardId]);