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