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 { HomeTreePicker } from '~/views-components/projects-tree-picker/home-tree-picker';
12 import { SEARCH_BAR_ADVANCE_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 { PropertyKeyInput } from '~/views-components/resource-properties-form/property-key-field';
17 import { PropertyValueInput, PropertyValueFieldProps } from '~/views-components/resource-properties-form/property-value-field';
18 import { VocabularyProp, connectVocabulary } from '~/views-components/resource-properties-form/property-field-common';
19 import { compose } from 'redux';
20 import { connect } from "react-redux";
21 import { RootState } from "~/store/store";
23 export const SearchBarTypeField = () =>
26 component={NativeSelectField}
28 { key: '', value: 'Any' },
29 { key: ResourceKind.COLLECTION, value: 'Collection' },
30 { key: ResourceKind.PROJECT, value: 'Project' },
31 { key: ResourceKind.PROCESS, value: 'Process' }
35 interface SearchBarClusterFieldProps {
36 clusters: { key: string, value: string }[];
39 export const SearchBarClusterField = connect(
40 (state: RootState) => ({
41 clusters: [{key: '', value: 'Any'}].concat(
43 .filter(s => s.loggedIn)
48 }))((props: SearchBarClusterFieldProps) => <Field
50 component={NativeSelectField}
51 items={props.clusters}/>
54 export const SearchBarProjectField = () =>
57 component={ProjectsPicker} />;
59 const ProjectsPicker = (props: WrappedFieldProps) =>
60 <div style={{ height: '100px', display: 'flex', flexDirection: 'column', overflow: 'overlay' }}>
62 pickerId={SEARCH_BAR_ADVANCE_FORM_PICKER_ID}
64 (_: any, { id }: TreeItem<ProjectsTreePickerItem>) => {
65 props.input.onChange(id);
70 export const SearchBarTrashField = () =>
73 component={CheckboxField}
76 export const SearchBarDateFromField = () =>
79 component={DateTextField} />;
81 export const SearchBarDateToField = () =>
84 component={DateTextField} />;
86 export const SearchBarPropertiesField = () =>
89 component={SearchBarAdvancedPropertiesView} />;
91 export const SearchBarKeyField = connectVocabulary(
92 ({ vocabulary }: VocabularyProp) =>
95 component={PropertyKeyInput}
96 vocabulary={vocabulary} />);
98 export const SearchBarValueField = compose(
100 formValues({ propertyKey: 'key' })
102 (props: PropertyValueFieldProps) =>
105 component={PropertyValueInput}
108 export const SearchBarSaveSearchField = () =>
111 component={CheckboxField}
112 label="Save query" />;
114 export const SearchBarQuerySearchField = () =>
117 component={TextField}
118 label="Query name" />;