1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import React from "react";
6 import { Typography } from "@material-ui/core";
7 import { TreeItem } from "components/tree/tree";
8 import { WrappedFieldProps } from 'redux-form';
9 import { ProjectsTreePicker } from 'views-components/projects-tree-picker/projects-tree-picker';
10 import { ProjectsTreePickerItem } from 'store/tree-picker/tree-picker-middleware';
11 import { PickerIdProp } from 'store/tree-picker/picker-id';
13 export const ProjectTreePickerField = (props: WrappedFieldProps & PickerIdProp) =>
14 <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
16 pickerId={props.pickerId}
17 toggleItemActive={handleChange(props)}
18 options={{ showOnlyOwned: false, showOnlyWritable: true }} />
19 {props.meta.dirty && props.meta.error &&
20 <Typography variant='caption' color='error'>
25 const handleChange = (props: WrappedFieldProps) =>
26 (_: any, { id }: TreeItem<ProjectsTreePickerItem>) =>
27 props.input.onChange(id);
29 export const CollectionTreePickerField = (props: WrappedFieldProps & PickerIdProp) =>
30 <div style={{ height: '200px', display: 'flex', flexDirection: 'column' }}>
32 pickerId={props.pickerId}
33 toggleItemActive={handleChange(props)}
34 options={{ showOnlyOwned: false, showOnlyWritable: true }}
36 {props.meta.dirty && props.meta.error &&
37 <Typography variant='caption' color='error'>