X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8095c4a7852131043b682b809ed78ca65386dd30..8e2f0bc7db026f646c3c08bc10fe4897bda7bdd8:/src/store/store.ts diff --git a/src/store/store.ts b/src/store/store.ts index 7beb099c1c..94f110a095 100644 --- a/src/store/store.ts +++ b/src/store/store.ts @@ -25,56 +25,64 @@ import { FavoritePanelMiddlewareService } from "./favorite-panel/favorite-panel- import { AllProcessesPanelMiddlewareService } from "./all-processes-panel/all-processes-panel-middleware-service"; import { collectionPanelReducer } from './collection-panel/collection-panel-reducer'; import { dialogReducer } from './dialog/dialog-reducer'; -import { ServiceRepository } from "~/services/services"; +import { ServiceRepository } from "services/services"; import { treePickerReducer } from './tree-picker/tree-picker-reducer'; -import { resourcesReducer } from '~/store/resources/resources-reducer'; +import { resourcesReducer } from 'store/resources/resources-reducer'; import { propertiesReducer } from './properties/properties-reducer'; import { fileUploaderReducer } from './file-uploader/file-uploader-reducer'; -import { TrashPanelMiddlewareService } from "~/store/trash-panel/trash-panel-middleware-service"; -import { TRASH_PANEL_ID } from "~/store/trash-panel/trash-panel-action"; +import { TrashPanelMiddlewareService } from "store/trash-panel/trash-panel-middleware-service"; +import { TRASH_PANEL_ID } from "store/trash-panel/trash-panel-action"; import { processLogsPanelReducer } from './process-logs-panel/process-logs-panel-reducer'; -import { processPanelReducer } from '~/store/process-panel/process-panel-reducer'; -import { SHARED_WITH_ME_PANEL_ID } from '~/store/shared-with-me-panel/shared-with-me-panel-actions'; +import { processPanelReducer } from 'store/process-panel/process-panel-reducer'; +import { SHARED_WITH_ME_PANEL_ID } from 'store/shared-with-me-panel/shared-with-me-panel-actions'; import { SharedWithMeMiddlewareService } from './shared-with-me-panel/shared-with-me-middleware-service'; import { progressIndicatorReducer } from './progress-indicator/progress-indicator-reducer'; -import { runProcessPanelReducer } from '~/store/run-process-panel/run-process-panel-reducer'; +import { runProcessPanelReducer } from 'store/run-process-panel/run-process-panel-reducer'; import { WorkflowMiddlewareService } from './workflow-panel/workflow-middleware-service'; import { WORKFLOW_PANEL_ID } from './workflow-panel/workflow-panel-actions'; -import { appInfoReducer } from '~/store/app-info/app-info-reducer'; +import { appInfoReducer } from 'store/app-info/app-info-reducer'; import { searchBarReducer } from './search-bar/search-bar-reducer'; -import { SEARCH_RESULTS_PANEL_ID } from '~/store/search-results-panel/search-results-panel-actions'; +import { SEARCH_RESULTS_PANEL_ID } from 'store/search-results-panel/search-results-panel-actions'; import { SearchResultsMiddlewareService } from './search-results-panel/search-results-middleware-service'; -import { virtualMachinesReducer } from "~/store/virtual-machines/virtual-machines-reducer"; -import { repositoriesReducer } from '~/store/repositories/repositories-reducer'; -import { keepServicesReducer } from '~/store/keep-services/keep-services-reducer'; -import { UserMiddlewareService } from '~/store/users/user-panel-middleware-service'; -import { USERS_PANEL_ID } from '~/store/users/users-actions'; -import { GroupsPanelMiddlewareService } from '~/store/groups-panel/groups-panel-middleware-service'; -import { GROUPS_PANEL_ID } from '~/store/groups-panel/groups-panel-actions'; -import { GroupDetailsPanelMiddlewareService } from '~/store/group-details-panel/group-details-panel-middleware-service'; -import { GROUP_DETAILS_PANEL_ID } from '~/store/group-details-panel/group-details-panel-actions'; -import { LINK_PANEL_ID } from '~/store/link-panel/link-panel-actions'; -import { LinkMiddlewareService } from '~/store/link-panel/link-panel-middleware-service'; -import { COMPUTE_NODE_PANEL_ID } from '~/store/compute-nodes/compute-nodes-actions'; -import { ComputeNodeMiddlewareService } from '~/store/compute-nodes/compute-nodes-middleware-service'; -import { API_CLIENT_AUTHORIZATION_PANEL_ID } from '~/store/api-client-authorizations/api-client-authorizations-actions'; -import { ApiClientAuthorizationMiddlewareService } from '~/store/api-client-authorizations/api-client-authorizations-middleware-service'; -import { PublicFavoritesMiddlewareService } from '~/store/public-favorites-panel/public-favorites-middleware-service'; -import { PUBLIC_FAVORITE_PANEL_ID } from '~/store/public-favorites-panel/public-favorites-action'; -import { publicFavoritesReducer } from '~/store/public-favorites/public-favorites-reducer'; +import { virtualMachinesReducer } from "store/virtual-machines/virtual-machines-reducer"; +import { repositoriesReducer } from 'store/repositories/repositories-reducer'; +import { keepServicesReducer } from 'store/keep-services/keep-services-reducer'; +import { UserMiddlewareService } from 'store/users/user-panel-middleware-service'; +import { USERS_PANEL_ID } from 'store/users/users-actions'; +import { UserProfileGroupsMiddlewareService } from 'store/user-profile/user-profile-groups-middleware-service'; +import { USER_PROFILE_PANEL_ID } from 'store/user-profile/user-profile-actions' +import { GroupsPanelMiddlewareService } from 'store/groups-panel/groups-panel-middleware-service'; +import { GROUPS_PANEL_ID } from 'store/groups-panel/groups-panel-actions'; +import { GroupDetailsPanelMembersMiddlewareService } from 'store/group-details-panel/group-details-panel-members-middleware-service'; +import { GroupDetailsPanelPermissionsMiddlewareService } from 'store/group-details-panel/group-details-panel-permissions-middleware-service'; +import { GROUP_DETAILS_MEMBERS_PANEL_ID, GROUP_DETAILS_PERMISSIONS_PANEL_ID } from 'store/group-details-panel/group-details-panel-actions'; +import { LINK_PANEL_ID } from 'store/link-panel/link-panel-actions'; +import { LinkMiddlewareService } from 'store/link-panel/link-panel-middleware-service'; +import { API_CLIENT_AUTHORIZATION_PANEL_ID } from 'store/api-client-authorizations/api-client-authorizations-actions'; +import { ApiClientAuthorizationMiddlewareService } from 'store/api-client-authorizations/api-client-authorizations-middleware-service'; +import { PublicFavoritesMiddlewareService } from 'store/public-favorites-panel/public-favorites-middleware-service'; +import { PUBLIC_FAVORITE_PANEL_ID } from 'store/public-favorites-panel/public-favorites-action'; +import { publicFavoritesReducer } from 'store/public-favorites/public-favorites-reducer'; import { linkAccountPanelReducer } from './link-account-panel/link-account-panel-reducer'; -import { CollectionsWithSameContentAddressMiddlewareService } from '~/store/collections-content-address-panel/collections-content-address-middleware-service'; -import { COLLECTIONS_CONTENT_ADDRESS_PANEL_ID } from '~/store/collections-content-address-panel/collections-content-address-panel-actions'; -import { ownerNameReducer } from '~/store/owner-name/owner-name-reducer'; -import { SubprocessMiddlewareService } from '~/store/subprocess-panel/subprocess-panel-middleware-service'; -import { SUBPROCESS_PANEL_ID } from '~/store/subprocess-panel/subprocess-panel-actions'; +import { CollectionsWithSameContentAddressMiddlewareService } from 'store/collections-content-address-panel/collections-content-address-middleware-service'; +import { COLLECTIONS_CONTENT_ADDRESS_PANEL_ID } from 'store/collections-content-address-panel/collections-content-address-panel-actions'; +import { ownerNameReducer } from 'store/owner-name/owner-name-reducer'; +import { SubprocessMiddlewareService } from 'store/subprocess-panel/subprocess-panel-middleware-service'; +import { SUBPROCESS_PANEL_ID } from 'store/subprocess-panel/subprocess-panel-actions'; import { ALL_PROCESSES_PANEL_ID } from './all-processes-panel/all-processes-panel-action'; -import { Config } from '~/common/config'; +import { Config } from 'common/config'; +import { pluginConfig } from 'plugins'; +import { MiddlewareListReducer } from 'common/plugintypes'; + +declare global { + interface Window { + __REDUX_DEVTOOLS_EXTENSION_COMPOSE__?: typeof compose; + } +} const composeEnhancers = (process.env.NODE_ENV === 'development' && - window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__ && - window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({ trace: true, traceLimit: 25 })) || + window && window.__REDUX_DEVTOOLS_EXTENSION_COMPOSE__) || compose; export type RootState = ReturnType>; @@ -108,18 +116,21 @@ export function configureStore(history: History, services: ServiceRepository, co const userPanelMiddleware = dataExplorerMiddleware( new UserMiddlewareService(services, USERS_PANEL_ID) ); + const userProfileGroupsMiddleware = dataExplorerMiddleware( + new UserProfileGroupsMiddlewareService(services, USER_PROFILE_PANEL_ID) + ); const groupsPanelMiddleware = dataExplorerMiddleware( new GroupsPanelMiddlewareService(services, GROUPS_PANEL_ID) ); - const groupDetailsPanelMiddleware = dataExplorerMiddleware( - new GroupDetailsPanelMiddlewareService(services, GROUP_DETAILS_PANEL_ID) + const groupDetailsPanelMembersMiddleware = dataExplorerMiddleware( + new GroupDetailsPanelMembersMiddlewareService(services, GROUP_DETAILS_MEMBERS_PANEL_ID) + ); + const groupDetailsPanelPermissionsMiddleware = dataExplorerMiddleware( + new GroupDetailsPanelPermissionsMiddlewareService(services, GROUP_DETAILS_PERMISSIONS_PANEL_ID) ); const linkPanelMiddleware = dataExplorerMiddleware( new LinkMiddlewareService(services, LINK_PANEL_ID) ); - const computeNodeMiddleware = dataExplorerMiddleware( - new ComputeNodeMiddlewareService(services, COMPUTE_NODE_PANEL_ID) - ); const apiClientAuthorizationMiddlewareService = dataExplorerMiddleware( new ApiClientAuthorizationMiddlewareService(services, API_CLIENT_AUTHORIZATION_PANEL_ID) ); @@ -142,7 +153,7 @@ export function configureStore(history: History, services: ServiceRepository, co return next(action); }; - const middlewares: Middleware[] = [ + let middlewares: Middleware[] = [ routerMiddleware(history), thunkMiddleware.withExtraArgument(services), authMiddleware(services), @@ -154,15 +165,22 @@ export function configureStore(history: History, services: ServiceRepository, co sharedWithMePanelMiddleware, workflowPanelMiddleware, userPanelMiddleware, + userProfileGroupsMiddleware, groupsPanelMiddleware, - groupDetailsPanelMiddleware, + groupDetailsPanelMembersMiddleware, + groupDetailsPanelPermissionsMiddleware, linkPanelMiddleware, - computeNodeMiddleware, apiClientAuthorizationMiddlewareService, publicFavoritesMiddleware, collectionsContentAddress, subprocessMiddleware, ]; + + const reduceMiddlewaresFn: (a: Middleware[], + b: MiddlewareListReducer) => Middleware[] = (a, b) => b(a, services); + + middlewares = pluginConfig.middlewares.reduce(reduceMiddlewaresFn, middlewares); + const enhancer = composeEnhancers(applyMiddleware(redirectToMiddleware, ...middlewares)); return createStore(rootReducer, enhancer); }