Init collection-files context menus
[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
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';
23
24 const composeEnhancers =
25     (process.env.NODE_ENV === 'development' &&
26         window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
27     compose;
28
29 export interface RootState {
30     auth: AuthState;
31     projects: ProjectState;
32     router: RouterState;
33     dataExplorer: DataExplorerState;
34     sidePanel: SidePanelState;
35     detailsPanel: DetailsPanelState;
36     contextMenu: ContextMenuState;
37     favorites: FavoritesState;
38     snackbar: SnackbarState;
39     collectionPanelFiles: CollectionPanelFilesState;
40 }
41
42 const rootReducer = combineReducers({
43     auth: authReducer,
44     projects: projectsReducer,
45     router: routerReducer,
46     dataExplorer: dataExplorerReducer,
47     sidePanel: sidePanelReducer,
48     detailsPanel: detailsPanelReducer,
49     contextMenu: contextMenuReducer,
50     form: formReducer,
51     favorites: favoritesReducer,
52     snackbar: snackbarReducer,
53     collectionPanelFiles: collectionPanelFilesReducer,
54 });
55
56
57 export function configureStore(history: History) {
58     const middlewares: Middleware[] = [
59         routerMiddleware(history),
60         thunkMiddleware,
61         projectPanelMiddleware,
62         favoritePanelMiddleware
63     ];
64     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
65     return createStore(rootReducer, enhancer);
66 }