X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/f0ac109691369516a5adf9370838cb4eacf16a45..06454ba23d896ba99d1f8ddca101088b96806966:/src/store/tree-picker/tree-picker-actions.ts diff --git a/src/store/tree-picker/tree-picker-actions.ts b/src/store/tree-picker/tree-picker-actions.ts index 5b29c4c2..5b04389a 100644 --- a/src/store/tree-picker/tree-picker-actions.ts +++ b/src/store/tree-picker/tree-picker-actions.ts @@ -2,51 +2,17 @@ // // SPDX-License-Identifier: AGPL-3.0 -import { default as unionize, ofType, UnionOf } from "unionize"; +import { unionize, ofType, UnionOf } from "~/common/unionize"; import { TreePickerNode } from "./tree-picker"; -import { receiveTreePickerData, TreePickerKind } from "../../views-components/project-tree-picker/project-tree-picker"; -import { mockProjectResource } from "../../models/test-utils"; -import { Dispatch } from "redux"; -import { RootState } from "../store"; -import { ServiceRepository } from "../../services/services"; export const treePickerActions = unionize({ - LOAD_TREE_PICKER_NODE: ofType<{ id: string, pickerId: string }>(), - LOAD_TREE_PICKER_NODE_SUCCESS: ofType<{ id: string, nodes: Array, pickerId: string }>(), - TOGGLE_TREE_PICKER_NODE_COLLAPSE: ofType<{ id: string, pickerId: string }>(), - TOGGLE_TREE_PICKER_NODE_SELECT: ofType<{ id: string, pickerId: string }>() -}, { - tag: 'type', - value: 'payload' - }); - -export const initPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - const uuid = services.authService.getUuid(); - - dispatch(getPickerTreeProjects(uuid)); - dispatch(getSharedWithMeProjectsPickerTree(uuid)); - dispatch(getFavoritesProjectsPickerTree(uuid)); -}; - -const getPickerTreeProjects = (uuid: string = '') => { - return getProjectsPickerTree(uuid, TreePickerKind.PROJECTS); -}; - -const getSharedWithMeProjectsPickerTree = (uuid: string = '') => { - return getProjectsPickerTree(uuid, TreePickerKind.SHARED_WITH_ME); -}; - -const getFavoritesProjectsPickerTree = (uuid: string = '') => { - return getProjectsPickerTree(uuid, TreePickerKind.FAVORITES); -}; - -const getProjectsPickerTree = (uuid: string, kind: string) => { - return receiveTreePickerData( - '', - [mockProjectResource({ uuid, name: kind })], - kind - ); -}; + LOAD_TREE_PICKER_NODE: ofType<{ nodeId: string, pickerId: string }>(), + LOAD_TREE_PICKER_NODE_SUCCESS: ofType<{ nodeId: string, nodes: Array, pickerId: string }>(), + TOGGLE_TREE_PICKER_NODE_COLLAPSE: ofType<{ nodeId: string, pickerId: string }>(), + TOGGLE_TREE_PICKER_NODE_SELECT: ofType<{ nodeId: string, pickerId: string }>(), + EXPAND_TREE_PICKER_NODES: ofType<{ nodeIds: string[], pickerId: string }>(), + RESET_TREE_PICKER: ofType<{ pickerId: string }>() +}); export type TreePickerAction = UnionOf;