Merge branch '13678-connect-data-explorer-to-the-store'
[arvados.git] / src / store / store.ts
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux';
6 import { routerMiddleware, routerReducer, RouterState } from "react-router-redux";
7 import thunkMiddleware from 'redux-thunk';
8 import { History } from "history";
9
10 import projectsReducer, { ProjectState } from "./project/project-reducer";
11 import sidePanelReducer, { SidePanelState } from './side-panel/side-panel-reducer';
12 import authReducer, { AuthState } from "./auth/auth-reducer";
13 import dataExplorerReducer, { DataExplorerState } from './data-explorer/data-explorer-reducer';
14 import collectionsReducer, { CollectionState } from "./collection/collection-reducer";
15
16 const composeEnhancers =
17     (process.env.NODE_ENV === 'development' &&
18         window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
19     compose;
20
21 export interface RootState {
22     auth: AuthState;
23     projects: ProjectState;
24     collections: CollectionState;
25     router: RouterState;
26     dataExplorer: DataExplorerState;
27     sidePanel: SidePanelState;
28 }
29
30 const rootReducer = combineReducers({
31     auth: authReducer,
32     projects: projectsReducer,
33     collections: collectionsReducer,
34     router: routerReducer,
35     dataExplorer: dataExplorerReducer,
36     sidePanel: sidePanelReducer
37 });
38
39
40 export default function configureStore(history: History) {
41     const middlewares: Middleware[] = [
42         routerMiddleware(history),
43         thunkMiddleware
44     ];
45     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
46     return createStore(rootReducer, enhancer);
47 }