1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import * as React from "react";
6 import { Field, WrappedFieldProps, FieldArray } from 'redux-form';
7 import { TextField, DateTextField } from "~/components/text-field/text-field";
8 import { CheckboxField } from '~/components/checkbox-field/checkbox-field';
9 import { NativeSelectField } from '~/components/select-field/select-field';
10 import { ResourceKind } from '~/models/resource';
11 import { HomeTreePicker } from '~/views-components/projects-tree-picker/home-tree-picker';
12 import { SEARCH_BAR_ADVANCED_FORM_PICKER_ID } from '~/store/search-bar/search-bar-actions';
13 import { SearchBarAdvancedPropertiesView } from '~/views-components/search-bar/search-bar-advanced-properties-view';
14 import { TreeItem } from "~/components/tree/tree";
15 import { ProjectsTreePickerItem } from "~/views-components/projects-tree-picker/generic-projects-tree-picker";
16 import { PropertyKeyField, } from '~/views-components/resource-properties-form/property-key-field';
17 import { PropertyValueField } from '~/views-components/resource-properties-form/property-value-field';
18 import { connect } from "react-redux";
19 import { RootState } from "~/store/store";
21 export const SearchBarTypeField = () =>
24 component={NativeSelectField}
26 { key: '', value: 'Any' },
27 { key: ResourceKind.COLLECTION, value: 'Collection' },
28 { key: ResourceKind.PROJECT, value: 'Project' },
29 { key: ResourceKind.PROCESS, value: 'Process' }
33 interface SearchBarClusterFieldProps {
34 clusters: { key: string, value: string }[];
37 export const SearchBarClusterField = connect(
38 (state: RootState) => ({
39 clusters: [{key: '', value: 'Any'}].concat(
41 .filter(s => s.loggedIn)
46 }))((props: SearchBarClusterFieldProps) => <Field
48 component={NativeSelectField}
49 items={props.clusters}/>
52 export const SearchBarProjectField = () =>
55 component={ProjectsPicker} />;
57 const ProjectsPicker = (props: WrappedFieldProps) =>
58 <div style={{ height: '100px', display: 'flex', flexDirection: 'column', overflow: 'overlay' }}>
60 pickerId={SEARCH_BAR_ADVANCED_FORM_PICKER_ID}
62 (_: any, { id }: TreeItem<ProjectsTreePickerItem>) => {
63 props.input.onChange(id);
68 export const SearchBarTrashField = () =>
71 component={CheckboxField}
74 export const SearchBarDateFromField = () =>
77 component={DateTextField} />;
79 export const SearchBarDateToField = () =>
82 component={DateTextField} />;
84 export const SearchBarPropertiesField = () =>
87 component={SearchBarAdvancedPropertiesView} />;
89 export const SearchBarKeyField = () =>
90 <PropertyKeyField skipValidation={true} />;
92 export const SearchBarValueField = () =>
93 <PropertyValueField skipValidation={true} />;
95 export const SearchBarSaveSearchField = () =>
98 component={CheckboxField}
99 label="Save query" />;
101 export const SearchBarQuerySearchField = () =>
104 component={TextField}
105 label="Query name" />;