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 { CollectionPanelFilesState } from './collection-panel/collection-panel-files/collection-panel-files-state';
22 import { collectionPanelFilesReducer } from './collection-panel/collection-panel-files/collections-panel-files-reducer';
24 const composeEnhancers =
25 (process.env.NODE_ENV === 'development' &&
26 window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
29 export interface RootState {
31 projects: ProjectState;
33 dataExplorer: DataExplorerState;
34 sidePanel: SidePanelState;
35 detailsPanel: DetailsPanelState;
36 contextMenu: ContextMenuState;
37 favorites: FavoritesState;
38 snackbar: SnackbarState;
39 collectionPanelFiles: CollectionPanelFilesState;
42 const rootReducer = combineReducers({
44 projects: projectsReducer,
45 router: routerReducer,
46 dataExplorer: dataExplorerReducer,
47 sidePanel: sidePanelReducer,
48 detailsPanel: detailsPanelReducer,
49 contextMenu: contextMenuReducer,
51 favorites: favoritesReducer,
52 snackbar: snackbarReducer,
53 collectionPanelFiles: collectionPanelFilesReducer,
57 export function configureStore(history: History) {
58 const middlewares: Middleware[] = [
59 routerMiddleware(history),
61 projectPanelMiddleware,
62 favoritePanelMiddleware
64 const enhancer = composeEnhancers(applyMiddleware(...middlewares));
65 return createStore(rootReducer, enhancer);