21838: Add redux saga and convert loadProject into saga
[arvados.git] / services / workbench2 / src / views-components / projects-tree-picker / shared-tree-picker.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { connect } from 'react-redux';
6 import { ProjectsTreePicker, ProjectsTreePickerProps } from 'views-components/projects-tree-picker/generic-projects-tree-picker';
7 import { Dispatch } from 'redux';
8 import { ShareMeIcon } from 'components/icon/icon';
9 import { loadProject } from 'store/tree-picker/tree-picker-actions';
10 import { SHARED_PROJECT_ID } from 'store/tree-picker/tree-picker-actions';
11
12 export const SharedTreePicker = connect(() => ({
13     rootItemIcon: ShareMeIcon,
14 }), (dispatch: Dispatch): Pick<ProjectsTreePickerProps, 'loadRootItem'> => ({
15     loadRootItem: (_, pickerId, includeCollections, includeDirectories, includeFiles, options) => {
16         dispatch<any>(loadProject({ id: SHARED_PROJECT_ID, pickerId, includeCollections, includeDirectories, includeFiles, loadShared: true, options }));
17     },
18 }))(ProjectsTreePicker);