Fix history rendering for DataQuery

This commit is contained in:
David Kaltschmidt
2018-11-22 11:02:53 +01:00
parent 331d419d4f
commit bbaa5b63c8
6 changed files with 116 additions and 14 deletions

View File

@@ -66,6 +66,8 @@ export async function getExploreUrl(
return url;
}
const clearQueryKeys: ((query: DataQuery) => object) = ({ key, refId, ...rest }) => rest;
export function parseUrlState(initial: string | undefined): ExploreUrlState {
if (initial) {
try {
@@ -93,7 +95,7 @@ export function parseUrlState(initial: string | undefined): ExploreUrlState {
export function serializeStateToUrlParam(state: ExploreState, compact?: boolean): string {
const urlState: ExploreUrlState = {
datasource: state.datasourceName,
queries: state.initialQueries.map(({ key, refId, ...rest }) => rest),
queries: state.initialQueries.map(clearQueryKeys),
range: state.range,
};
if (compact) {
@@ -182,3 +184,8 @@ export function updateHistory(history: HistoryItem[], datasourceId: string, quer
store.setObject(historyKey, history);
return history;
}
export function clearHistory(datasourceId: string) {
const historyKey = `grafana.explore.history.${datasourceId}`;
store.delete(historyKey);
}