Connect project explorer to the store
[arvados-workbench2.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 import projectsReducer, { ProjectState } from "./project/project-reducer";
10 import authReducer, { AuthState } from "./auth/auth-reducer";
11 import collectionsReducer from "./collection/collection-reducer";
12 import dataExplorerReducer, { DataExplorerState } from './data-explorer/data-explorer-reducer';
13
14 const composeEnhancers =
15     (process.env.NODE_ENV === 'development' &&
16     window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
17     compose;
18
19 export interface RootState {
20     auth: AuthState;
21     projects: ProjectState;
22     router: RouterState;
23     dataExplorer: DataExplorerState;
24 }
25
26 const rootReducer = combineReducers({
27     auth: authReducer,
28     projects: projectsReducer,
29     collections: collectionsReducer,
30     router: routerReducer,
31     dataExplorer: dataExplorerReducer
32 });
33
34
35 export default function configureStore(history: History) {
36     const middlewares: Middleware[] = [
37         routerMiddleware(history),
38         thunkMiddleware
39     ];
40     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
41     return createStore(rootReducer, enhancer);
42 }