diff --git a/public/app/features/dashboard/utils/getPanelMenu.test.ts b/public/app/features/dashboard/utils/getPanelMenu.test.ts index 7024e4d3cd2..496e825cb69 100644 --- a/public/app/features/dashboard/utils/getPanelMenu.test.ts +++ b/public/app/features/dashboard/utils/getPanelMenu.test.ts @@ -353,7 +353,6 @@ describe('getPanelMenu()', () => { }); describe('onNavigateToExplore', () => { - const testSubUrl = '/testSubUrl'; const testUrl = '/testUrl'; const windowOpen = jest.fn(); let event: any; @@ -387,15 +386,16 @@ describe('getPanelMenu()', () => { expect(windowOpen).toHaveBeenLastCalledWith(testUrl); }); - it('should navigate to url with subUrl', () => { - config.appSubUrl = testSubUrl; + it('should navigate to url without subUrl even if appSubUrl is set', () => { + const exploreUrl = '/explore?param1=a¶m2=b'; + config.appSubUrl = 'grafana'; explore.onClick!(event); const openInNewWindow = navigateSpy.mock.calls[0][1].openInNewWindow; - openInNewWindow(testUrl); - - expect(windowOpen).toHaveBeenLastCalledWith(`${testSubUrl}${testUrl}`); + openInNewWindow(`${exploreUrl}`); + // When opening in a new window, onNavigateToExplore should not include the subUrl, as getExploreUrl already handles it. + expect(windowOpen).toHaveBeenLastCalledWith(`${exploreUrl}`); }); }); diff --git a/public/app/features/dashboard/utils/getPanelMenu.ts b/public/app/features/dashboard/utils/getPanelMenu.ts index 9be15abd15c..0f521bff6f8 100644 --- a/public/app/features/dashboard/utils/getPanelMenu.ts +++ b/public/app/features/dashboard/utils/getPanelMenu.ts @@ -1,6 +1,5 @@ import { PanelMenuItem, urlUtil, PluginExtensionLink } from '@grafana/data'; import { locationService } from '@grafana/runtime'; -import config from 'app/core/config'; import { createErrorNotification } from 'app/core/copy/appNotification'; import { t } from 'app/core/internationalization'; import { notifyApp } from 'app/core/reducers/appNotification'; @@ -88,8 +87,7 @@ export function getPanelMenu( const onNavigateToExplore = (event: React.MouseEvent) => { event.preventDefault(); - const openInNewWindow = - event.ctrlKey || event.metaKey ? (url: string) => window.open(`${config.appSubUrl}${url}`) : undefined; + const openInNewWindow = event.ctrlKey || event.metaKey ? (url: string) => window.open(url) : undefined; store.dispatch( navigateToExplore(panel, { timeRange: getTimeSrv().timeRange(), diff --git a/public/app/features/explore/state/main.ts b/public/app/features/explore/state/main.ts index ed3e789cecc..42a3a054d7f 100644 --- a/public/app/features/explore/state/main.ts +++ b/public/app/features/explore/state/main.ts @@ -2,7 +2,7 @@ import { createAction } from '@reduxjs/toolkit'; import { isEqual } from 'lodash'; import { AnyAction } from 'redux'; -import { SplitOpenOptions, TimeRange, EventBusSrv } from '@grafana/data'; +import { SplitOpenOptions, TimeRange, EventBusSrv, locationUtil } from '@grafana/data'; import { locationService } from '@grafana/runtime'; import { generateExploreId, GetExploreUrlArguments } from 'app/core/utils/explore'; import { PanelModel } from 'app/features/dashboard/state/PanelModel'; @@ -151,7 +151,7 @@ export const navigateToExplore = ( return; } - locationService.push(path!); + locationService.push(locationUtil.stripBaseFromUrl(path!)); }; };