1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Collection } from "../../models/collection";
6 import { default as unionize, ofType, UnionOf } from "unionize";
7 import { Dispatch } from "redux";
8 import { collectionService } from "../../services/services";
10 const actions = unionize({
11 CREATE_COLLECTION: ofType<Collection>(),
12 REMOVE_COLLECTION: ofType<string>(),
13 COLLECTIONS_REQUEST: ofType<any>(),
14 COLLECTIONS_SUCCESS: ofType<{ collections: Collection[] }>(),
20 export const getCollectionList = (parentUuid?: string) => (dispatch: Dispatch): Promise<Collection[]> => {
21 dispatch(actions.COLLECTIONS_REQUEST());
22 return collectionService.getCollectionList(parentUuid).then(collections => {
23 dispatch(actions.COLLECTIONS_SUCCESS({collections}));
28 export type CollectionAction = UnionOf<typeof actions>;
29 export default actions;