2018-07-09 03:28:20 -05:00
|
|
|
import { createStore, applyMiddleware, compose, combineReducers } from 'redux';
|
|
|
|
import thunk from 'redux-thunk';
|
2019-02-11 02:34:14 -06:00
|
|
|
// 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';
|
2018-09-12 02:15:18 -05:00
|
|
|
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';
|
2018-09-28 04:05:34 -05:00
|
|
|
import dataSourcesReducers from 'app/features/datasources/state/reducers';
|
2018-10-03 02:43:10 -05:00
|
|
|
import usersReducers from 'app/features/users/state/reducers';
|
2019-02-06 07:35:53 -06:00
|
|
|
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';
|
2018-07-09 03:28:20 -05:00
|
|
|
|
2018-10-16 08:36:33 -05:00
|
|
|
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,
|
2018-09-12 02:15:18 -05:00
|
|
|
...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,
|
2018-09-28 04:05:34 -05:00
|
|
|
...dataSourcesReducers,
|
2018-10-03 02:43:10 -05:00
|
|
|
...usersReducers,
|
2019-02-06 07:35:53 -06:00
|
|
|
...userReducers,
|
2018-10-26 07:15:37 -05:00
|
|
|
...organizationReducers,
|
2018-10-16 08:36:33 -05:00
|
|
|
};
|
2018-07-09 03:28:20 -05:00
|
|
|
|
2018-10-16 08:36:33 -05:00
|
|
|
export function addRootReducer(reducers) {
|
|
|
|
Object.assign(rootReducers, ...reducers);
|
|
|
|
}
|
|
|
|
|
2018-07-09 03:28:20 -05:00
|
|
|
export function configureStore() {
|
|
|
|
const composeEnhancers = (window as any).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ || compose;
|
2018-09-10 02:53:52 -05:00
|
|
|
|
2018-10-16 08:36:33 -05:00
|
|
|
const rootReducer = combineReducers(rootReducers);
|
|
|
|
|
2018-09-10 02:53:52 -05:00
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
// DEV builds we had the logger middleware
|
2019-02-11 02:34:14 -06:00
|
|
|
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
|
2018-09-10 02:53:52 -05:00
|
|
|
} else {
|
2018-11-05 09:54:48 -06:00
|
|
|
setStore(createStore(rootReducer, {}, composeEnhancers(applyMiddleware(thunk))));
|
2018-09-10 02:53:52 -05:00
|
|
|
}
|
2018-07-09 02:17:38 -05:00
|
|
|
}
|