diff --git a/public/app/core/utils/explore.test.ts b/public/app/core/utils/explore.test.ts index cc0c14ee176..8cbe7bcbdee 100644 --- a/public/app/core/utils/explore.test.ts +++ b/public/app/core/utils/explore.test.ts @@ -59,6 +59,20 @@ describe('state functions', () => { }); }); + it('should not return a query for mode in the url', () => { + // Previous versions of Grafana included "Explore mode" in the URL; this should not be treated as a query. + const paramValue = + '["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"mode":"Metrics"},{"ui":[true,true,true,"none"]}]'; + expect(parseUrlState(paramValue)).toMatchObject({ + datasource: 'x-ray-datasource', + queries: [{ queryType: 'getTraceSummaries' }], + range: { + from: 'now-1h', + to: 'now', + }, + }); + }); + it('should return queries if queryType is present in the url', () => { const paramValue = '["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]'; diff --git a/public/app/core/utils/explore.ts b/public/app/core/utils/explore.ts index 691b1d93a9d..f72474b2bb9 100644 --- a/public/app/core/utils/explore.ts +++ b/public/app/core/utils/explore.ts @@ -243,7 +243,7 @@ export function parseUrlState(initial: string | undefined): ExploreUrlState { }; const datasource = parsed[ParseUrlStateIndex.Datasource]; const parsedSegments = parsed.slice(ParseUrlStateIndex.SegmentsStart); - const queries = parsedSegments.filter(segment => !isSegment(segment, 'ui', 'originPanelId')); + const queries = parsedSegments.filter(segment => !isSegment(segment, 'ui', 'originPanelId', 'mode')); const originPanelId = parsedSegments.filter(segment => isSegment(segment, 'originPanelId'))[0]; return { datasource, queries, range, originPanelId };