X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/353c39122f1ebbcb47cf5ae4d2ea641b60439614..9f4bca6531631fc5ed21435f31db36720d58512b:/src/views-components/project-tree-picker/project-tree-picker.tsx

diff --git a/src/views-components/project-tree-picker/project-tree-picker.tsx b/src/views-components/project-tree-picker/project-tree-picker.tsx
index 30acf2a731..3859180f0e 100644
--- a/src/views-components/project-tree-picker/project-tree-picker.tsx
+++ b/src/views-components/project-tree-picker/project-tree-picker.tsx
@@ -16,11 +16,12 @@ import { createTreePickerNode } from "~/store/tree-picker/tree-picker";
 import { RootState } from "~/store/store";
 import { ServiceRepository } from "~/services/services";
 import { FilterBuilder } from "~/common/api/filter-builder";
-import { mockProjectResource } from "~/models/test-utils";
+import { WrappedFieldProps } from 'redux-form';
 
-type ProjectTreePickerProps = Pick<TreePickerProps, 'toggleItemActive' | 'toggleItemOpen'>;
+type ProjectTreePickerProps = Pick<TreePickerProps, 'onContextMenu' | 'toggleItemActive' | 'toggleItemOpen'>;
 
 const mapDispatchToProps = (dispatch: Dispatch, props: { onChange: (projectUuid: string) => void }): ProjectTreePickerProps => ({
+    onContextMenu: () => { return; },
     toggleItemActive: (nodeId, status, pickerId) => {
         getNotSelectedTreePickerKind(pickerId)
             .forEach(pickerId => dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_SELECT({ nodeId: '', pickerId })));
@@ -142,31 +143,17 @@ export const receiveTreePickerData = (nodeId: string, projects: ProjectResource[
         dispatch(treePickerActions.TOGGLE_TREE_PICKER_NODE_COLLAPSE({ nodeId, pickerId }));
     };
 
-export const initPickerProjectTree = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
-    const uuid = services.authService.getUuid();
-
-    dispatch<any>(getPickerTreeProjects(uuid));
-    dispatch<any>(getSharedWithMeProjectsPickerTree(uuid));
-    dispatch<any>(getFavoritesProjectsPickerTree(uuid));
-};
-
-const getPickerTreeProjects = (uuid: string = '') => {
-    return getProjectsPickerTree(uuid, TreePickerId.PROJECTS);
-};
-
-const getSharedWithMeProjectsPickerTree = (uuid: string = '') => {
-    return getProjectsPickerTree(uuid, TreePickerId.SHARED_WITH_ME);
-};
-
-const getFavoritesProjectsPickerTree = (uuid: string = '') => {
-    return getProjectsPickerTree(uuid, TreePickerId.FAVORITES);
-};
-
-const getProjectsPickerTree = (uuid: string, kind: string) => {
-    return receiveTreePickerData(
-        '',
-        [mockProjectResource({ uuid, name: kind })],
-        kind
-    );
-};
+export const ProjectTreePickerField = (props: WrappedFieldProps) =>
+    <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
+        <ProjectTreePicker onChange={handleChange(props)} />
+        {props.meta.dirty && props.meta.error &&
+            <Typography variant='caption' color='error'>
+                {props.meta.error}
+            </Typography>}
+    </div>;
+
+const handleChange = (props: WrappedFieldProps) => (value: string) =>
+    props.input.value === value
+        ? props.input.onChange('')
+        : props.input.onChange(value);
 
