1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { Dispatch } from "redux";
6 import { RootState } from "~/store/store";
7 import { ServiceRepository } from "~/services/services";
8 import { mockProjectResource } from "~/models/test-utils";
9 import { treePickerActions, receiveTreePickerProjectsData } from "~/store/tree-picker/tree-picker-actions";
10 import { TreePickerId } from '~/models/tree';
12 export const resetPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
13 dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.PROJECTS}));
14 dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.SHARED_WITH_ME}));
15 dispatch<any>(treePickerActions.RESET_TREE_PICKER({pickerId: TreePickerId.FAVORITES}));
17 dispatch<any>(initPickerProjectTree());
20 export const initPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
21 const uuid = services.authService.getUuid();
23 dispatch<any>(getPickerTreeProjects(uuid));
24 dispatch<any>(getSharedWithMeProjectsPickerTree(uuid));
25 dispatch<any>(getFavoritesProjectsPickerTree(uuid));
28 const getPickerTreeProjects = (uuid: string = '') => {
29 return getProjectsPickerTree(uuid, TreePickerId.PROJECTS);
32 const getSharedWithMeProjectsPickerTree = (uuid: string = '') => {
33 return getProjectsPickerTree(uuid, TreePickerId.SHARED_WITH_ME);
36 const getFavoritesProjectsPickerTree = (uuid: string = '') => {
37 return getProjectsPickerTree(uuid, TreePickerId.FAVORITES);
40 const getProjectsPickerTree = (uuid: string, kind: string) => {
41 return receiveTreePickerProjectsData(
43 [mockProjectResource({ uuid, name: kind })],