1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { unionize, ofType, UnionOf } from "unionize";
6 import { CommonResourceService } from "../../common/api/common-resource-service";
7 import { apiClient } from "../../common/api/server-api";
8 import { Dispatch } from "redux";
9 import { ResourceKind } from "../../models/resource";
10 import { CollectionResource } from "../../models/collection";
12 export const collectionPanelActions = unionize({
13 LOAD_COLLECTION: ofType<{ uuid: string, kind: ResourceKind }>(),
14 LOAD_COLLECTION_SUCCESS: ofType<{ item: CollectionResource }>(),
15 }, { tag: 'type', value: 'payload' });
17 export type CollectionPanelAction = UnionOf<typeof collectionPanelActions>;
19 export const loadCollection = (uuid: string, kind: ResourceKind) =>
20 (dispatch: Dispatch) => {
21 dispatch(collectionPanelActions.LOAD_COLLECTION({ uuid, kind }));
22 return new CommonResourceService(apiClient, "collections")
25 dispatch(collectionPanelActions.LOAD_COLLECTION_SUCCESS({ item: item as CollectionResource }));