|
@@ -61,7 +61,6 @@ export const makeExploreItemState = (): ExploreItemState => ({
|
|
|
history: [],
|
|
history: [],
|
|
|
initialQueries: [],
|
|
initialQueries: [],
|
|
|
initialized: false,
|
|
initialized: false,
|
|
|
- modifiedQueries: [],
|
|
|
|
|
queryTransactions: [],
|
|
queryTransactions: [],
|
|
|
queryIntervals: { interval: '15s', intervalMs: DEFAULT_GRAPH_INTERVAL },
|
|
queryIntervals: { interval: '15s', intervalMs: DEFAULT_GRAPH_INTERVAL },
|
|
|
range: DEFAULT_RANGE,
|
|
range: DEFAULT_RANGE,
|
|
@@ -91,16 +90,9 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
.addMapper({
|
|
.addMapper({
|
|
|
filter: addQueryRowAction,
|
|
filter: addQueryRowAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
- const { initialQueries, modifiedQueries, queryTransactions } = state;
|
|
|
|
|
|
|
+ const { initialQueries, queryTransactions } = state;
|
|
|
const { index, query } = action.payload;
|
|
const { index, query } = action.payload;
|
|
|
|
|
|
|
|
- // Add new query row after given index, keep modifications of existing rows
|
|
|
|
|
- const nextModifiedQueries = [
|
|
|
|
|
- ...modifiedQueries.slice(0, index + 1),
|
|
|
|
|
- { ...query },
|
|
|
|
|
- ...initialQueries.slice(index + 1),
|
|
|
|
|
- ];
|
|
|
|
|
-
|
|
|
|
|
// Add to initialQueries, which will cause a new row to be rendered
|
|
// Add to initialQueries, which will cause a new row to be rendered
|
|
|
const nextQueries = [...initialQueries.slice(0, index + 1), { ...query }, ...initialQueries.slice(index + 1)];
|
|
const nextQueries = [...initialQueries.slice(0, index + 1), { ...query }, ...initialQueries.slice(index + 1)];
|
|
|
|
|
|
|
@@ -116,7 +108,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
...state,
|
|
...state,
|
|
|
initialQueries: nextQueries,
|
|
initialQueries: nextQueries,
|
|
|
logsHighlighterExpressions: undefined,
|
|
logsHighlighterExpressions: undefined,
|
|
|
- modifiedQueries: nextModifiedQueries,
|
|
|
|
|
queryTransactions: nextQueryTransactions,
|
|
queryTransactions: nextQueryTransactions,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -125,20 +116,12 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
filter: changeQueryAction,
|
|
filter: changeQueryAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
const { initialQueries, queryTransactions } = state;
|
|
const { initialQueries, queryTransactions } = state;
|
|
|
- let { modifiedQueries } = state;
|
|
|
|
|
- const { query, index, override } = action.payload;
|
|
|
|
|
-
|
|
|
|
|
- // Fast path: only change modifiedQueries to not trigger an update
|
|
|
|
|
- modifiedQueries[index] = query;
|
|
|
|
|
- if (!override) {
|
|
|
|
|
- return { ...state, modifiedQueries };
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ const { query, index } = action.payload;
|
|
|
|
|
|
|
|
// Override path: queries are completely reset
|
|
// Override path: queries are completely reset
|
|
|
const nextQuery: DataQuery = { ...query, ...generateEmptyQuery(index) };
|
|
const nextQuery: DataQuery = { ...query, ...generateEmptyQuery(index) };
|
|
|
const nextQueries = [...initialQueries];
|
|
const nextQueries = [...initialQueries];
|
|
|
nextQueries[index] = nextQuery;
|
|
nextQueries[index] = nextQuery;
|
|
|
- modifiedQueries = [...nextQueries];
|
|
|
|
|
|
|
|
|
|
// Discard ongoing transaction related to row query
|
|
// Discard ongoing transaction related to row query
|
|
|
const nextQueryTransactions = queryTransactions.filter(qt => qt.rowIndex !== index);
|
|
const nextQueryTransactions = queryTransactions.filter(qt => qt.rowIndex !== index);
|
|
@@ -146,7 +129,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
return {
|
|
return {
|
|
|
...state,
|
|
...state,
|
|
|
initialQueries: nextQueries,
|
|
initialQueries: nextQueries,
|
|
|
- modifiedQueries: nextQueries.slice(),
|
|
|
|
|
queryTransactions: nextQueryTransactions,
|
|
queryTransactions: nextQueryTransactions,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -177,7 +159,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
return {
|
|
return {
|
|
|
...state,
|
|
...state,
|
|
|
initialQueries: queries.slice(),
|
|
initialQueries: queries.slice(),
|
|
|
- modifiedQueries: queries.slice(),
|
|
|
|
|
queryTransactions: [],
|
|
queryTransactions: [],
|
|
|
showingStartPage: Boolean(state.StartPage),
|
|
showingStartPage: Boolean(state.StartPage),
|
|
|
};
|
|
};
|
|
@@ -202,7 +183,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
range,
|
|
range,
|
|
|
initialQueries: queries,
|
|
initialQueries: queries,
|
|
|
initialized: true,
|
|
initialized: true,
|
|
|
- modifiedQueries: queries.slice(),
|
|
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
@@ -268,14 +248,14 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
.addMapper({
|
|
.addMapper({
|
|
|
filter: modifyQueriesAction,
|
|
filter: modifyQueriesAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
- const { initialQueries, modifiedQueries, queryTransactions } = state;
|
|
|
|
|
|
|
+ const { initialQueries, queryTransactions } = state;
|
|
|
const { modification, index, modifier } = action.payload;
|
|
const { modification, index, modifier } = action.payload;
|
|
|
let nextQueries: DataQuery[];
|
|
let nextQueries: DataQuery[];
|
|
|
let nextQueryTransactions;
|
|
let nextQueryTransactions;
|
|
|
if (index === undefined) {
|
|
if (index === undefined) {
|
|
|
// Modify all queries
|
|
// Modify all queries
|
|
|
nextQueries = initialQueries.map((query, i) => ({
|
|
nextQueries = initialQueries.map((query, i) => ({
|
|
|
- ...modifier(modifiedQueries[i], modification),
|
|
|
|
|
|
|
+ ...modifier({ ...query }, modification),
|
|
|
...generateEmptyQuery(i),
|
|
...generateEmptyQuery(i),
|
|
|
}));
|
|
}));
|
|
|
// Discard all ongoing transactions
|
|
// Discard all ongoing transactions
|
|
@@ -285,7 +265,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
nextQueries = initialQueries.map((query, i) => {
|
|
nextQueries = initialQueries.map((query, i) => {
|
|
|
// Synchronize all queries with local query cache to ensure consistency
|
|
// Synchronize all queries with local query cache to ensure consistency
|
|
|
// TODO still needed?
|
|
// TODO still needed?
|
|
|
- return i === index ? { ...modifier(modifiedQueries[i], modification), ...generateEmptyQuery(i) } : query;
|
|
|
|
|
|
|
+ return i === index ? { ...modifier({ ...query }, modification), ...generateEmptyQuery(i) } : query;
|
|
|
});
|
|
});
|
|
|
nextQueryTransactions = queryTransactions
|
|
nextQueryTransactions = queryTransactions
|
|
|
// Consume the hint corresponding to the action
|
|
// Consume the hint corresponding to the action
|
|
@@ -301,7 +281,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
return {
|
|
return {
|
|
|
...state,
|
|
...state,
|
|
|
initialQueries: nextQueries,
|
|
initialQueries: nextQueries,
|
|
|
- modifiedQueries: nextQueries.slice(),
|
|
|
|
|
queryTransactions: nextQueryTransactions,
|
|
queryTransactions: nextQueryTransactions,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -347,11 +326,8 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
filter: removeQueryRowAction,
|
|
filter: removeQueryRowAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
const { datasourceInstance, initialQueries, queryIntervals, queryTransactions } = state;
|
|
const { datasourceInstance, initialQueries, queryIntervals, queryTransactions } = state;
|
|
|
- let { modifiedQueries } = state;
|
|
|
|
|
const { index } = action.payload;
|
|
const { index } = action.payload;
|
|
|
|
|
|
|
|
- modifiedQueries = [...modifiedQueries.slice(0, index), ...modifiedQueries.slice(index + 1)];
|
|
|
|
|
-
|
|
|
|
|
if (initialQueries.length <= 1) {
|
|
if (initialQueries.length <= 1) {
|
|
|
return state;
|
|
return state;
|
|
|
}
|
|
}
|
|
@@ -371,7 +347,6 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
...results,
|
|
...results,
|
|
|
initialQueries: nextQueries,
|
|
initialQueries: nextQueries,
|
|
|
logsHighlighterExpressions: undefined,
|
|
logsHighlighterExpressions: undefined,
|
|
|
- modifiedQueries: nextQueries.slice(),
|
|
|
|
|
queryTransactions: nextQueryTransactions,
|
|
queryTransactions: nextQueryTransactions,
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
@@ -412,7 +387,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
filter: setQueriesAction,
|
|
filter: setQueriesAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
const { queries } = action.payload;
|
|
const { queries } = action.payload;
|
|
|
- return { ...state, initialQueries: queries.slice(), modifiedQueries: queries.slice() };
|
|
|
|
|
|
|
+ return { ...state, initialQueries: queries.slice() };
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
.addMapper({
|
|
.addMapper({
|
|
@@ -461,7 +436,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
|
|
|
.addMapper({
|
|
.addMapper({
|
|
|
filter: queriesImportedAction,
|
|
filter: queriesImportedAction,
|
|
|
mapper: (state, action): ExploreItemState => {
|
|
mapper: (state, action): ExploreItemState => {
|
|
|
- return { ...state, initialQueries: action.payload.queries, modifiedQueries: action.payload.queries.slice() };
|
|
|
|
|
|
|
+ return { ...state, initialQueries: action.payload.queries };
|
|
|
},
|
|
},
|
|
|
})
|
|
})
|
|
|
.create();
|
|
.create();
|