Commit 34dd1a22 by Hugo Häggmark

Fixed bug with removing a QueryRow thats not part of nextQueries

parent 96aef3ba
...@@ -331,7 +331,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta ...@@ -331,7 +331,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
.addMapper({ .addMapper({
filter: removeQueryRowAction, filter: removeQueryRowAction,
mapper: (state, action): ExploreItemState => { mapper: (state, action): ExploreItemState => {
const { datasourceInstance, initialQueries, queryIntervals, queryTransactions } = state; const { datasourceInstance, initialQueries, queryIntervals, queryTransactions, queryKeys } = state;
const { index } = action.payload; const { index } = action.payload;
if (initialQueries.length <= 1) { if (initialQueries.length <= 1) {
...@@ -339,9 +339,10 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta ...@@ -339,9 +339,10 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
} }
const nextQueries = [...initialQueries.slice(0, index), ...initialQueries.slice(index + 1)]; const nextQueries = [...initialQueries.slice(0, index), ...initialQueries.slice(index + 1)];
const nextQueryKeys = [...queryKeys.slice(0, index), ...queryKeys.slice(index + 1)];
// Discard transactions related to row query // Discard transactions related to row query
const nextQueryTransactions = queryTransactions.filter(qt => qt.rowIndex !== index); const nextQueryTransactions = queryTransactions.filter(qt => nextQueries.some(nq => nq.key === qt.query.key));
const results = calculateResultsFromQueryTransactions( const results = calculateResultsFromQueryTransactions(
nextQueryTransactions, nextQueryTransactions,
datasourceInstance, datasourceInstance,
...@@ -354,7 +355,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta ...@@ -354,7 +355,7 @@ export const itemReducer = reducerFactory<ExploreItemState>({} as ExploreItemSta
initialQueries: nextQueries, initialQueries: nextQueries,
logsHighlighterExpressions: undefined, logsHighlighterExpressions: undefined,
queryTransactions: nextQueryTransactions, queryTransactions: nextQueryTransactions,
queryKeys: getQueryKeys(nextQueries, state.datasourceInstance), queryKeys: nextQueryKeys,
}; };
}, },
}) })
......
import { createStore, applyMiddleware, compose, combineReducers } from 'redux'; import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
// import { createLogger } from 'redux-logger'; import { createLogger } from 'redux-logger';
import sharedReducers from 'app/core/reducers'; import sharedReducers from 'app/core/reducers';
import alertingReducers from 'app/features/alerting/state/reducers'; import alertingReducers from 'app/features/alerting/state/reducers';
import teamsReducers from 'app/features/teams/state/reducers'; import teamsReducers from 'app/features/teams/state/reducers';
...@@ -39,7 +39,7 @@ export function configureStore() { ...@@ -39,7 +39,7 @@ export function configureStore() {
if (process.env.NODE_ENV !== 'production') { if (process.env.NODE_ENV !== 'production') {
// DEV builds we had the logger middleware // DEV builds we had the logger middleware
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk)))); setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk, createLogger()))));
} else { } else {
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk)))); setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment