grafana/public/app/store/configureStore.ts

49 lines
1.8 KiB
TypeScript
Raw Normal View History

import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
import thunk from 'redux-thunk';
// import { createLogger } from 'redux-logger';
2018-08-31 06:24:36 -05:00
import sharedReducers from 'app/core/reducers';
2018-09-02 13:36:03 -05:00
import alertingReducers from 'app/features/alerting/state/reducers';
2018-09-05 08:13:21 -05:00
import teamsReducers from 'app/features/teams/state/reducers';
2018-09-25 09:23:43 -05:00
import apiKeysReducers from 'app/features/api-keys/state/reducers';
import foldersReducers from 'app/features/folders/state/reducers';
2018-09-13 09:00:02 -05:00
import dashboardReducers from 'app/features/dashboard/state/reducers';
2019-01-10 07:24:31 -06:00
import exploreReducers from 'app/features/explore/state/reducers';
2018-09-25 07:53:55 -05:00
import pluginReducers from 'app/features/plugins/state/reducers';
import dataSourcesReducers from 'app/features/datasources/state/reducers';
2018-10-03 02:43:10 -05:00
import usersReducers from 'app/features/users/state/reducers';
import userReducers from 'app/features/profile/state/reducers';
2018-10-26 07:15:37 -05:00
import organizationReducers from 'app/features/org/state/reducers';
2018-11-05 09:54:48 -06:00
import { setStore } from './store';
const rootReducers = {
2018-09-02 13:36:03 -05:00
...sharedReducers,
...alertingReducers,
2018-09-05 08:13:21 -05:00
...teamsReducers,
2018-09-25 09:23:43 -05:00
...apiKeysReducers,
...foldersReducers,
2018-09-13 09:00:02 -05:00
...dashboardReducers,
2019-01-10 07:24:31 -06:00
...exploreReducers,
2018-09-25 07:53:55 -05:00
...pluginReducers,
...dataSourcesReducers,
2018-10-03 02:43:10 -05:00
...usersReducers,
...userReducers,
2018-10-26 07:15:37 -05:00
...organizationReducers,
};
export function addRootReducer(reducers) {
Object.assign(rootReducers, ...reducers);
}
export function configureStore() {
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
const rootReducer = combineReducers(rootReducers);
if (process.env.NODE_ENV !== 'production') {
// DEV builds we had the logger middleware
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
} else {
2018-11-05 09:54:48 -06:00
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
}
2018-07-09 02:17:38 -05:00
}