X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a92bb3822b537682ca621df3c05a458b9ae3420b..4407b22fba72783a428ebbaf165cc579ea4c5a23:/src/store/store.ts diff --git a/src/store/store.ts b/src/store/store.ts index 975debe8..e7dbe16f 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -2,20 +2,54 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { createStore, applyMiddleware, compose, Middleware } from 'redux'; -import { default as rootReducer, RootState } from "./root-reducer"; -import { routerMiddleware } from "react-router-redux"; +import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux'; +import { routerMiddleware, routerReducer, RouterState } from "react-router-redux"; +import thunkMiddleware from 'redux-thunk'; import { History } from "history"; +import { projectsReducer, ProjectState } from "./project/project-reducer"; +import { sidePanelReducer, SidePanelState } from './side-panel/side-panel-reducer'; +import { authReducer, AuthState } from "./auth/auth-reducer"; +import { dataExplorerReducer, DataExplorerState } from './data-explorer/data-explorer-reducer'; +import { projectPanelMiddleware } from './project-panel/project-panel-middleware'; +import { detailsPanelReducer, DetailsPanelState } from './details-panel/details-panel-reducer'; +import { contextMenuReducer, ContextMenuState } from './context-menu/context-menu-reducer'; +import { FavoritesState, favoritesReducer } from './favorites/favorites-reducer'; + const composeEnhancers = (process.env.NODE_ENV === 'development' && - window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || + window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; -export default function configureStore(initialState: RootState, history: History) { +export interface RootState { + auth: AuthState; + projects: ProjectState; + router: RouterState; + dataExplorer: DataExplorerState; + sidePanel: SidePanelState; + detailsPanel: DetailsPanelState; + contextMenu: ContextMenuState; + favorites: FavoritesState; +} + +const rootReducer = combineReducers({ + auth: authReducer, + projects: projectsReducer, + router: routerReducer, + dataExplorer: dataExplorerReducer, + sidePanel: sidePanelReducer, + detailsPanel: detailsPanelReducer, + contextMenu: contextMenuReducer, + favorites: favoritesReducer, +}); + + +export function configureStore(history: History) { const middlewares: Middleware[] = [ - routerMiddleware(history) + routerMiddleware(history), + thunkMiddleware, + projectPanelMiddleware ]; const enhancer = composeEnhancers(applyMiddleware(...middlewares)); - return createStore(rootReducer, initialState!, enhancer); + return createStore(rootReducer, enhancer); }