Merge branch '13633-data-explorer-column-filtering'
[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
13 const composeEnhancers =
14     (process.env.NODE_ENV === 'development' &&
15     window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
16     compose;
17
18 export interface RootState {
19     auth: AuthState;
20     projects: ProjectState;
21     router: RouterState;
22 }
23
24 const rootReducer = combineReducers({
25     auth: authReducer,
26     projects: projectsReducer,
27     collections: collectionsReducer,
28     router: routerReducer
29 });
30
31
32 export default function configureStore(initialState: RootState, history: History) {
33     const middlewares: Middleware[] = [
34         routerMiddleware(history),
35         thunkMiddleware
36     ];
37     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
38     return createStore(rootReducer, initialState!, enhancer);
39 }