Commit 40fbea97 by Ivana Huckova Committed by David

Explore: Take root_url setting into account when redirecting from dashboard to explore (#19447)

* Explore: Take root_url setting into account when redirecting from dashboard to explore

* Explore: Move adding of subath to getExploreUrl function

* Explore: Fix explore redirect for key bindings
parent 234a2c59
......@@ -3,6 +3,7 @@ import _ from 'lodash';
import coreModule from 'app/core/core_module';
import appEvents from 'app/core/app_events';
import { getExploreUrl } from 'app/core/utils/explore';
import locationUtil from 'app/core/utils/location_util';
import { store } from 'app/store/store';
import Mousetrap from 'mousetrap';
......@@ -220,8 +221,10 @@ export class KeybindingSrv {
const panel = dashboard.getPanelById(dashboard.meta.focusPanelId);
const datasource = await this.datasourceSrv.get(panel.datasource);
const url = await getExploreUrl(panel, panel.targets, datasource, this.datasourceSrv, this.timeSrv);
if (url) {
this.$timeout(() => this.$location.url(url));
const urlWithoutBase = locationUtil.stripBaseFromUrl(url);
if (urlWithoutBase) {
this.$timeout(() => this.$location.url(urlWithoutBase));
}
}
});
......
......@@ -90,7 +90,8 @@ export async function getExploreUrl(
const exploreState = JSON.stringify({ ...state, originPanelId: panel.id });
url = renderUrl('/explore', { left: exploreState });
}
return url;
const finalUrl = config.appSubUrl + url;
return finalUrl;
}
export function buildQueryTransaction(
......
......@@ -251,13 +251,6 @@ class MetricsPanelCtrl extends PanelCtrl {
}
return items;
}
async explore() {
const url = await getExploreUrl(this.panel, this.panel.targets, this.datasource, this.datasourceSrv, this.timeSrv);
if (url) {
this.$timeout(() => this.$location.url(url));
}
}
}
export { MetricsPanelCtrl };
......@@ -10,6 +10,9 @@ jest.mock('app/core/config', () => {
name: 'test',
},
},
config: {
appSubUrl: 'test',
},
};
});
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment