From 1468bab360440a33b1e0fdb890503be45393ee02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Torkel=20=C3=96degaard?= Date: Fri, 10 Apr 2020 10:08:42 +0200 Subject: [PATCH] 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 --- public/app/store/configureStore.ts | 51 +++++++++++++++++++++++++++--- 1 file changed, 47 insertions(+), 4 deletions(-) diff --git a/public/app/store/configureStore.ts b/public/app/store/configureStore.ts index d039b3422df..30fa248249b 100644 --- a/public/app/store/configureStore.ts +++ b/public/app/store/configureStore.ts @@ -1,7 +1,6 @@ import { configureStore as reduxConfigureStore, getDefaultMiddleware } from '@reduxjs/toolkit'; import { createLogger } from 'redux-logger'; -import thunk, { ThunkMiddleware } from 'redux-thunk'; - +import { ThunkMiddleware } from 'redux-thunk'; import { setStore } from './store'; import { StoreState } from 'app/types/store'; import { toggleLogActionsMiddleware } from 'app/core/middlewares/application'; @@ -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({ + thunk: true, + serializableCheck: false, + immutableCheck: false, + } as any); const store = reduxConfigureStore({ reducer: createRootReducer(), - middleware: [...getDefaultMiddleware(), ...middleware] as [ThunkMiddleware], + middleware: [...reduxDefaultMiddleware, ...middleware] as [ThunkMiddleware], devTools: process.env.NODE_ENV !== 'production', preloadedState: { navIndex: buildInitialState(), @@ -36,3 +41,41 @@ export function configureStore() { setStore(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', + ]; +} +*/