X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/52cc3b912c703c24bc90e67aaf24e8ad912d3ebf..fbec771115f1872bdadc0572a5c5059be68f1aca:/src/store/store.ts diff --git a/src/store/store.ts b/src/store/store.ts index 68c5d823..37343619 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -2,16 +2,28 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { createStore, applyMiddleware, compose, Middleware, combineReducers } from 'redux'; +import { createStore, applyMiddleware, compose, Middleware, combineReducers, Store, Action, Dispatch } 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 collectionsReducer, { CollectionState } from "./collection/collection-reducer"; +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 { detailsPanelReducer, DetailsPanelState } from './details-panel/details-panel-reducer'; +import { contextMenuReducer, ContextMenuState } from './context-menu/context-menu-reducer'; +import { reducer as formReducer } from 'redux-form'; +import { FavoritesState, favoritesReducer } from './favorites/favorites-reducer'; +import { snackbarReducer, SnackbarState } from './snackbar/snackbar-reducer'; +import { dataExplorerMiddleware } from "./data-explorer/data-explorer-middleware"; +import { FAVORITE_PANEL_ID } from "./favorite-panel/favorite-panel-action"; +import { PROJECT_PANEL_ID } from "./project-panel/project-panel-action"; +import { ProjectPanelMiddlewareService } from "./project-panel/project-panel-middleware-service"; +import { FavoritePanelMiddlewareService } from "./favorite-panel/favorite-panel-middleware-service"; +import { CollectionCreatorState, collectionCreationReducer } from './collections/creator/collection-creator-reducer'; +import { CollectionPanelState, collectionPanelReducer } from './collection-panel/collection-panel-reducer'; +import { ServiceRepository } from "../services/services"; const composeEnhancers = (process.env.NODE_ENV === 'development' && @@ -21,26 +33,47 @@ const composeEnhancers = export interface RootState { auth: AuthState; projects: ProjectState; - collections: CollectionState; + collectionCreation: CollectionCreatorState; router: RouterState; dataExplorer: DataExplorerState; sidePanel: SidePanelState; + collectionPanel: CollectionPanelState; + detailsPanel: DetailsPanelState; + contextMenu: ContextMenuState; + favorites: FavoritesState; + snackbar: SnackbarState; } -const rootReducer = combineReducers({ - auth: authReducer, - projects: projectsReducer, - collections: collectionsReducer, - router: routerReducer, - dataExplorer: dataExplorerReducer, - sidePanel: sidePanelReducer -}); +export type RootStore = Store & { dispatch: Dispatch }; +export function configureStore(history: History, services: ServiceRepository): RootStore { + const rootReducer = combineReducers({ + auth: authReducer(services), + projects: projectsReducer, + collectionCreation: collectionCreationReducer, + router: routerReducer, + dataExplorer: dataExplorerReducer, + sidePanel: sidePanelReducer, + collectionPanel: collectionPanelReducer, + detailsPanel: detailsPanelReducer, + contextMenu: contextMenuReducer, + form: formReducer, + favorites: favoritesReducer, + snackbar: snackbarReducer, + }); + + const projectPanelMiddleware = dataExplorerMiddleware( + new ProjectPanelMiddlewareService(services, PROJECT_PANEL_ID) + ); + const favoritePanelMiddleware = dataExplorerMiddleware( + new FavoritePanelMiddlewareService(services, FAVORITE_PANEL_ID) + ); -export default function configureStore(history: History) { const middlewares: Middleware[] = [ routerMiddleware(history), - thunkMiddleware + thunkMiddleware.withExtraArgument(services), + projectPanelMiddleware, + favoritePanelMiddleware ]; const enhancer = composeEnhancers(applyMiddleware(...middlewares)); return createStore(rootReducer, enhancer);