Commit 1468bab3 by Torkel Ödegaard Committed by GitHub

Redux: Added config to redux development middlewares that checks for mutations…

Redux: Added config to redux development middlewares that checks for mutations and serializability (#23492)

* Redux: Added config to redux development middlewares that checks for mutations and serializability

* Disable these middlewares, they are too slow

* Update public/app/store/configureStore.ts

* Update public/app/store/configureStore.ts

* Prettier fix

Co-authored-by: Dominik Prokop <dominik.prokop@grafana.com>
parent a5661574
import { configureStore as reduxConfigureStore, getDefaultMiddleware } from '@reduxjs/toolkit'; import { configureStore as reduxConfigureStore, getDefaultMiddleware } from '@reduxjs/toolkit';
import { createLogger } from 'redux-logger'; import { createLogger } from 'redux-logger';
import thunk, { ThunkMiddleware } from 'redux-thunk'; import { ThunkMiddleware } from 'redux-thunk';
import { setStore } from './store'; import { setStore } from './store';
import { StoreState } from 'app/types/store'; import { StoreState } from 'app/types/store';
import { toggleLogActionsMiddleware } from 'app/core/middlewares/application'; import { toggleLogActionsMiddleware } from 'app/core/middlewares/application';
...@@ -22,11 +21,17 @@ export function configureStore() { ...@@ -22,11 +21,17 @@ export function configureStore() {
}, },
}); });
const middleware = process.env.NODE_ENV !== 'production' ? [toggleLogActionsMiddleware, thunk, logger] : [thunk]; const middleware = process.env.NODE_ENV !== 'production' ? [toggleLogActionsMiddleware, logger] : [];
const reduxDefaultMiddleware = getDefaultMiddleware<StoreState>({
thunk: true,
serializableCheck: false,
immutableCheck: false,
} as any);
const store = reduxConfigureStore<StoreState>({ const store = reduxConfigureStore<StoreState>({
reducer: createRootReducer(), reducer: createRootReducer(),
middleware: [...getDefaultMiddleware<StoreState>(), ...middleware] as [ThunkMiddleware<StoreState>], middleware: [...reduxDefaultMiddleware, ...middleware] as [ThunkMiddleware<StoreState>],
devTools: process.env.NODE_ENV !== 'production', devTools: process.env.NODE_ENV !== 'production',
preloadedState: { preloadedState: {
navIndex: buildInitialState(), navIndex: buildInitialState(),
...@@ -36,3 +41,41 @@ export function configureStore() { ...@@ -36,3 +41,41 @@ export function configureStore() {
setStore(store); setStore(store);
return store; return store;
} }
/*
function getActionsToIgnoreSerializableCheckOn() {
return [
'dashboard/setPanelAngularComponent',
'dashboard/panelModelAndPluginReady',
'dashboard/dashboardInitCompleted',
'plugins/panelPluginLoaded',
'explore/initializeExplore',
'explore/changeRange',
'explore/updateDatasourceInstance',
'explore/queryStoreSubscription',
'explore/queryStreamUpdated',
];
}
function getPathsToIgnoreMutationAndSerializableCheckOn() {
return [
'plugins.panels',
'dashboard.panels',
'dashboard.getModel',
'payload.plugin',
'panelEditorNew.getPanel',
'panelEditorNew.getSourcePanel',
'panelEditorNew.getData',
'explore.left.queryResponse',
'explore.right.queryResponse',
'explore.left.datasourceInstance',
'explore.right.datasourceInstance',
'explore.left.range',
'explore.left.eventBridge',
'explore.right.eventBridge',
'explore.right.range',
'explore.left.querySubscription',
'explore.right.querySubscription',
];
}
*/
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