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 SearchBarPastVersionsField = () =>
77 component={CheckboxField}
78 label="Past versions" />;
80 export const SearchBarDateFromField = () =>
83 component={DateTextField} />;
85 export const SearchBarDateToField = () =>
88 component={DateTextField} />;
90 export const SearchBarPropertiesField = () =>
93 component={SearchBarAdvancedPropertiesView} />;
95 export const SearchBarKeyField = () =>
96 <PropertyKeyField skipValidation={true} />;
98 export const SearchBarValueField = () =>
99 <PropertyValueField skipValidation={true} />;
101 export const SearchBarSaveSearchField = () =>
104 component={CheckboxField}
105 label="Save query" />;
107 export const SearchBarQuerySearchField = () =>
110 component={TextField}
111 label="Query name" />;