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 { favoritePanelMiddleware } from "./favorite-panel/favorite-panel-middleware";
18 import { reducer as formReducer } from 'redux-form';
19 import { FavoritesState, favoritesReducer } from './favorites/favorites-reducer';
20 import { snackbarReducer, SnackbarState } from './snackbar/snackbar-reducer';
21 import { CollectionCreatorState, collectionCreationReducer } from './collections/creator/collection-creator-reducer';
22 import { CollectionPanelState, collectionPanelReducer } from './collection-panel/collection-panel-reducer';
24 const composeEnhancers =
25 (process.env.NODE_ENV === 'development' &&
26 window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
29 export interface RootState {
31 projects: ProjectState;
32 collectionCreation: CollectionCreatorState;
34 dataExplorer: DataExplorerState;
35 sidePanel: SidePanelState;
36 collectionPanel: CollectionPanelState;
37 detailsPanel: DetailsPanelState;
38 contextMenu: ContextMenuState;
39 favorites: FavoritesState;
40 snackbar: SnackbarState;
43 const rootReducer = combineReducers({
45 projects: projectsReducer,
46 collectionCreation: collectionCreationReducer,
47 router: routerReducer,
48 dataExplorer: dataExplorerReducer,
49 sidePanel: sidePanelReducer,
50 collectionPanel: collectionPanelReducer,
51 detailsPanel: detailsPanelReducer,
52 contextMenu: contextMenuReducer,
54 favorites: favoritesReducer,
55 snackbar: snackbarReducer,
59 export function configureStore(history: History) {
60 const middlewares: Middleware[] = [
61 routerMiddleware(history),
63 projectPanelMiddleware,
64 favoritePanelMiddleware
66 const enhancer = composeEnhancers(applyMiddleware(...middlewares));
67 return createStore(rootReducer, enhancer);