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