1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
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";
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 { projectPanelMiddleware } from './project-panel/project-panel-middleware';
15 import { detailsPanelReducer, DetailsPanelState } from './details-panel/details-panel-reducer';
16 import { contextMenuReducer, ContextMenuState } from './context-menu/context-menu-reducer';
17 import { FavoritesState, favoritesReducer } from './favorites/favorites-reducer';
19 const composeEnhancers =
20 (process.env.NODE_ENV === 'development' &&
21 window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
24 export interface RootState {
26 projects: ProjectState;
28 dataExplorer: DataExplorerState;
29 sidePanel: SidePanelState;
30 detailsPanel: DetailsPanelState;
31 contextMenu: ContextMenuState;
32 favorites: FavoritesState;
35 const rootReducer = combineReducers({
37 projects: projectsReducer,
38 router: routerReducer,
39 dataExplorer: dataExplorerReducer,
40 sidePanel: sidePanelReducer,
41 detailsPanel: detailsPanelReducer,
42 contextMenu: contextMenuReducer,
43 favorites: favoritesReducer,
47 export function configureStore(history: History) {
48 const middlewares: Middleware[] = [
49 routerMiddleware(history),
51 projectPanelMiddleware
53 const enhancer = composeEnhancers(applyMiddleware(...middlewares));
54 return createStore(rootReducer, enhancer);