Add favorite panel
[arvados.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
19 const composeEnhancers =
20     (process.env.NODE_ENV === 'development' &&
21         window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) ||
22     compose;
23
24 export interface RootState {
25     auth: AuthState;
26     projects: ProjectState;
27     router: RouterState;
28     dataExplorer: DataExplorerState;
29     sidePanel: SidePanelState;
30     detailsPanel: DetailsPanelState;
31     contextMenu: ContextMenuState;
32 }
33
34 const rootReducer = combineReducers({
35     auth: authReducer,
36     projects: projectsReducer,
37     router: routerReducer,
38     dataExplorer: dataExplorerReducer,
39     sidePanel: sidePanelReducer,
40     detailsPanel: detailsPanelReducer,
41     contextMenu: contextMenuReducer
42 });
43
44
45 export function configureStore(history: History) {
46     const middlewares: Middleware[] = [
47         routerMiddleware(history),
48         thunkMiddleware,
49         projectPanelMiddleware,
50         favoritePanelMiddleware
51     ];
52     const enhancer = composeEnhancers(applyMiddleware(...middlewares));
53     return createStore(rootReducer, enhancer);
54 }