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, formValues } 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 { ClusterObjectType } from '~/models/search-bar';
12 import { HomeTreePicker } from '~/views-components/projects-tree-picker/home-tree-picker';
13 import { SEARCH_BAR_ADVANCE_FORM_PICKER_ID } from '~/store/search-bar/search-bar-actions';
14 import { SearchBarAdvancedPropertiesView } from '~/views-components/search-bar/search-bar-advanced-properties-view';
15 import { TreeItem } from "~/components/tree/tree";
16 import { ProjectsTreePickerItem } from "~/views-components/projects-tree-picker/generic-projects-tree-picker";
17 import { PropertyKeyInput } from '~/views-components/resource-properties-form/property-key-field';
18 import { PropertyValueInput, PropertyValueFieldProps } from '~/views-components/resource-properties-form/property-value-field';
19 import { VocabularyProp, connectVocabulary } from '~/views-components/resource-properties-form/property-field-common';
20 import { compose } from 'redux';
22 export const SearchBarTypeField = () =>
25 component={NativeSelectField}
27 { key: '', value: 'Any' },
28 { key: ResourceKind.COLLECTION, value: 'Collection' },
29 { key: ResourceKind.PROJECT, value: 'Project' },
30 { key: ResourceKind.PROCESS, value: 'Process' }
33 export const SearchBarClusterField = () =>
36 component={NativeSelectField}
38 { key: '', value: 'Any' },
39 { key: ClusterObjectType.INDIANAPOLIS, value: 'Indianapolis' },
40 { key: ClusterObjectType.KAISERAUGST, value: 'Kaiseraugst' },
41 { key: ClusterObjectType.PENZBERG, value: 'Penzberg' }
44 export const SearchBarProjectField = () =>
47 component={ProjectsPicker} />;
49 const ProjectsPicker = (props: WrappedFieldProps) =>
50 <div style={{ height: '100px', display: 'flex', flexDirection: 'column', overflow: 'overlay' }}>
52 pickerId={SEARCH_BAR_ADVANCE_FORM_PICKER_ID}
54 (_: any, { id }: TreeItem<ProjectsTreePickerItem>) => {
55 props.input.onChange(id);
60 export const SearchBarTrashField = () =>
63 component={CheckboxField}
66 export const SearchBarDateFromField = () =>
69 component={DateTextField} />;
71 export const SearchBarDateToField = () =>
74 component={DateTextField} />;
76 export const SearchBarPropertiesField = () =>
79 component={SearchBarAdvancedPropertiesView} />;
81 export const SearchBarKeyField = connectVocabulary(
82 ({ vocabulary }: VocabularyProp) =>
85 component={PropertyKeyInput}
86 vocabulary={vocabulary} />);
88 export const SearchBarValueField = compose(
90 formValues({ propertyKey: 'key' })
92 (props: PropertyValueFieldProps) =>
95 component={PropertyValueInput}
98 export const SearchBarSaveSearchField = () =>
101 component={CheckboxField}
102 label="Save query" />;
104 export const SearchBarQuerySearchField = () =>
107 component={TextField}
108 label="Query name" />;