Merge pull request #12630 from grafana/davkal/explore-empty-error

Dont parse empty explore state from url
This commit is contained in:
David 2018-07-17 16:48:23 +02:00 committed by GitHub
commit 5c6adbbada
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -33,18 +33,20 @@ function makeTimeSeriesList(dataList, options) {
}); });
} }
function parseInitialState(initial) { function parseInitialState(initial: string | undefined) {
try { if (initial) {
const parsed = JSON.parse(decodePathComponent(initial)); try {
return { const parsed = JSON.parse(decodePathComponent(initial));
datasource: parsed.datasource, return {
queries: parsed.queries.map(q => q.query), datasource: parsed.datasource,
range: parsed.range, queries: parsed.queries.map(q => q.query),
}; range: parsed.range,
} catch (e) { };
console.error(e); } catch (e) {
return { queries: [], range: DEFAULT_RANGE }; console.error(e);
}
} }
return { datasource: null, queries: [], range: DEFAULT_RANGE };
} }
interface IExploreState { interface IExploreState {