The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/store/configureStore.ts

72 lines
2.2 KiB

import { configureStore as reduxConfigureStore } from '@reduxjs/toolkit';
import { setStore } from './store';
import { StoreState } from 'app/types/store';
import { addReducer, createRootReducer } from '../core/reducers/root';
import { buildInitialState } from '../core/reducers/navModel';
import { ThunkMiddlewareFor } from '@reduxjs/toolkit/src/getDefaultMiddleware';
import { AnyAction } from 'redux';
export function addRootReducer(reducers: any) {
// this is ok now because we add reducers before configureStore is called
// in the future if we want to add reducers during runtime
// we'll have to solve this in a more dynamic way
addReducer(reducers);
}
export function configureStore(initialState?: Partial<StoreState>) {
const store = reduxConfigureStore<
StoreState,
AnyAction,
ReadonlyArray<ThunkMiddlewareFor<StoreState, { thunk: true }>>
>({
reducer: createRootReducer(),
middleware: (getDefaultMiddleware) =>
getDefaultMiddleware({ thunk: true, serializableCheck: false, immutableCheck: false }),
devTools: process.env.NODE_ENV !== 'production',
preloadedState: {
navIndex: buildInitialState(),
...initialState,
},
});
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',
];
}
*/