1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Project } from "../../models/project";
6 import { default as unionize, ofType, UnionOf } from "unionize";
7 import { projectService } from "../../services/services";
8 import { Dispatch } from "redux";
10 const actions = unionize({
11 CREATE_PROJECT: ofType<Project>(),
12 REMOVE_PROJECT: ofType<string>(),
13 PROJECTS_REQUEST: ofType<any>(),
14 PROJECTS_SUCCESS: ofType<{ projects: Project[], parentItemId?: string }>(),
15 TOGGLE_PROJECT_TREE_ITEM: ofType<string>()
21 export const getProjectList = (parentUuid?: string) => (dispatch: Dispatch): Promise<Project[]> => {
22 dispatch(actions.PROJECTS_REQUEST());
23 return projectService.getProjectList(parentUuid).then(projects => {
24 dispatch(actions.PROJECTS_SUCCESS({projects, parentItemId: parentUuid}));
29 export type ProjectAction = UnionOf<typeof actions>;
30 export default actions;