mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 10:20:29 -06:00
Explore: parse queryType from explore url (#26349)
* Explore: parse queryType from explore url * Modify explore.ts parse logic
This commit is contained in:
parent
ba50e96544
commit
7b218b7198
@ -65,7 +65,9 @@ describe('state functions', () => {
|
||||
});
|
||||
|
||||
it('returns a valid Explore state from a compact URL parameter', () => {
|
||||
const paramValue = '%5B"now-1h","now","Local","5m",%7B"expr":"metric"%7D,"ui"%5D';
|
||||
// ["now-1h","now","Local",{"expr":"metric"},{"ui":[true,true,true,"none"]}]
|
||||
const paramValue =
|
||||
'%5B"now-1h","now","Local",%7B"expr":"metric"%7D,%7B%22ui%22:%5Btrue,true,true,%22none%22%5D%7D%5D';
|
||||
expect(parseUrlState(paramValue)).toMatchObject({
|
||||
datasource: 'Local',
|
||||
queries: [{ expr: 'metric' }],
|
||||
@ -75,6 +77,20 @@ describe('state functions', () => {
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
it('should return queries if queryType is present in the url', () => {
|
||||
// ["now-1h","now","x-ray-datasource",{"queryType":"getTraceSummaries"},{"ui":[true,true,true,"none"]}]
|
||||
const paramValue =
|
||||
'%5B"now-1h","now","x-ray-datasource",%7B"queryType":"getTraceSummaries"%7D,%7B%22ui%22:%5Btrue,true,true,%22none%22%5D%7D%5D';
|
||||
expect(parseUrlState(paramValue)).toMatchObject({
|
||||
datasource: 'x-ray-datasource',
|
||||
queries: [{ queryType: 'getTraceSummaries' }],
|
||||
range: {
|
||||
from: 'now-1h',
|
||||
to: 'now',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('serializeStateToUrlParam', () => {
|
||||
|
@ -248,8 +248,7 @@ export function parseUrlState(initial: string | undefined): ExploreUrlState {
|
||||
};
|
||||
const datasource = parsed[ParseUrlStateIndex.Datasource];
|
||||
const parsedSegments = parsed.slice(ParseUrlStateIndex.SegmentsStart);
|
||||
const metricProperties = ['expr', 'expression', 'target', 'datasource', 'query'];
|
||||
const queries = parsedSegments.filter(segment => isSegment(segment, ...metricProperties));
|
||||
const queries = parsedSegments.filter(segment => !isSegment(segment, 'ui', 'originPanelId'));
|
||||
|
||||
const uiState = parsedSegments.filter(segment => isSegment(segment, 'ui'))[0];
|
||||
const ui = uiState
|
||||
|
Loading…
Reference in New Issue
Block a user