Make backwards compatible (#29212)

This commit is contained in:
Timothy Palpant 2020-11-19 15:08:16 -05:00 committed by GitHub
parent 2dc260a486
commit c94e8e61a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 1 deletions

View File

@ -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', () => { it('should return queries if queryType is present in the url', () => {
const paramValue = const paramValue =
'["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]'; '["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]';

View File

@ -243,7 +243,7 @@ export function parseUrlState(initial: string | undefined): ExploreUrlState {
}; };
const datasource = parsed[ParseUrlStateIndex.Datasource]; const datasource = parsed[ParseUrlStateIndex.Datasource];
const parsedSegments = parsed.slice(ParseUrlStateIndex.SegmentsStart); 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]; const originPanelId = parsedSegments.filter(segment => isSegment(segment, 'originPanelId'))[0];
return { datasource, queries, range, originPanelId }; return { datasource, queries, range, originPanelId };