X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/6cb43ce8d9ab8345a1b2a5abd961c7c134f5c607..4a24786b1ab2199d3841226eed83be56a83645fc:/src/store/collection-panel/collection-panel-action.ts diff --git a/src/store/collection-panel/collection-panel-action.ts b/src/store/collection-panel/collection-panel-action.ts index 3c660165..ee95590c 100644 --- a/src/store/collection-panel/collection-panel-action.ts +++ b/src/store/collection-panel/collection-panel-action.ts @@ -3,26 +3,33 @@ // SPDX-License-Identifier: AGPL-3.0 import { unionize, ofType, UnionOf } from "unionize"; -import { CommonResourceService } from "../../common/api/common-resource-service"; -import { apiClient } from "../../common/api/server-api"; import { Dispatch } from "redux"; import { ResourceKind } from "../../models/resource"; import { CollectionResource } from "../../models/collection"; +import { collectionPanelFilesAction } from "./collection-panel-files/collection-panel-files-actions"; +import { createTree } from "../../models/tree"; +import { RootState } from "../store"; +import { ServiceRepository } from "../../services/services"; export const collectionPanelActions = unionize({ LOAD_COLLECTION: ofType<{ uuid: string, kind: ResourceKind }>(), - LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(), + LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>() }, { tag: 'type', value: 'payload' }); export type CollectionPanelAction = UnionOf; export const loadCollection = (uuid: string, kind: ResourceKind) => - (dispatch: Dispatch) => { + (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(collectionPanelActions.LOAD_COLLECTION({ uuid, kind })); - return new CommonResourceService(apiClient, "collections") + dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES({ files: createTree() })); + return services.collectionService .get(uuid) .then(item => { - dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource })); + dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item })); + return services.collectionFilesService.getFiles(item.uuid); + }) + .then(files => { + dispatch(collectionPanelFilesAction.SET_COLLECTION_FILES(files)); }); };