X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/2f56a774af3f3401f3a1ed405a9fa70f9efa5890..c038a5258d5790773ccca89a192c8c2b7dcd86cb:/src/views-components/search-bar/search-bar-advanced-view.tsx?ds=sidebyside diff --git a/src/views-components/search-bar/search-bar-advanced-view.tsx b/src/views-components/search-bar/search-bar-advanced-view.tsx index a8d65a49..c7573501 100644 --- a/src/views-components/search-bar/search-bar-advanced-view.tsx +++ b/src/views-components/search-bar/search-bar-advanced-view.tsx @@ -3,28 +3,27 @@ // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; -import { reduxForm, reset, InjectedFormProps } from 'redux-form'; +import { reduxForm, InjectedFormProps, reset } from 'redux-form'; import { compose, Dispatch } from 'redux'; import { Paper, StyleRulesCallback, withStyles, WithStyles, Button, Grid, IconButton, CircularProgress } from '@material-ui/core'; -import { SearchView } from '~/store/search-bar/search-bar-reducer'; -import { SEARCH_BAR_ADVANCE_FORM_NAME, saveQuery } from '~/store/search-bar/search-bar-actions'; +import { SEARCH_BAR_ADVANCE_FORM_NAME, searchAdvanceData } from '~/store/search-bar/search-bar-actions'; import { ArvadosTheme } from '~/common/custom-theme'; import { CloseIcon } from '~/components/icon/icon'; import { SearchBarAdvanceFormData } from '~/models/search-bar'; -import { - SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField, +import { + SearchBarTypeField, SearchBarClusterField, SearchBarProjectField, SearchBarTrashField, SearchBarDateFromField, SearchBarDateToField, SearchBarPropertiesField, SearchBarSaveSearchField, SearchBarQuerySearchField } from '~/views-components/form-fields/search-bar-form-fields'; -type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper' +type CssRules = 'container' | 'closeIcon' | 'label' | 'buttonWrapper' | 'button' | 'circularProgress' | 'searchView' | 'selectGrid'; const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ container: { padding: theme.spacing.unit * 2, borderBottom: `1px solid ${theme.palette.grey["200"]}` - }, + }, closeIcon: { position: 'absolute', top: '12px', @@ -36,8 +35,8 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ alignSelf: 'center' }, buttonWrapper: { - paddingRight: '14px', - paddingTop: '14px', + marginRight: '14px', + marginTop: '14px', position: 'relative', }, button: { @@ -45,7 +44,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ }, circularProgress: { position: 'absolute', - top: -9, + top: 0, bottom: 0, left: 0, right: 0, @@ -60,43 +59,50 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => ({ } }); -interface SearchBarAdvancedViewDataProps { +// ToDo: maybe we should remove invalid and prostine +interface SearchBarAdvancedViewFormDataProps { submitting: boolean; invalid: boolean; pristine: boolean; } -interface SearchBarAdvancedViewActionProps { - setView: (currentView: string) => void; - saveQuery: (data: SearchBarAdvanceFormData) => void; +// ToDo: maybe we should remove tags +export interface SearchBarAdvancedViewDataProps { + tags: any; +} + +export interface SearchBarAdvancedViewActionProps { + closeAdvanceView: () => void; } -type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps +type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps; + +type SearchBarAdvancedViewFormProps = SearchBarAdvancedViewProps & SearchBarAdvancedViewFormDataProps & InjectedFormProps & WithStyles; const validate = (values: any) => { const errors: any = {}; - if (values.dateFrom && values.dateTo ) { + if (values.dateFrom && values.dateTo) { if (new Date(values.dateFrom).getTime() > new Date(values.dateTo).getTime()) { errors.dateFrom = 'Invalid date'; } - } + } return errors; }; export const SearchBarAdvancedView = compose( - reduxForm({ + reduxForm({ form: SEARCH_BAR_ADVANCE_FORM_NAME, validate, onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => { - dispatch(saveQuery(data)); + dispatch(searchAdvanceData(data)); dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME)); } }), withStyles(styles))( - ({ classes, setView, handleSubmit, submitting, invalid, pristine }: SearchBarAdvancedViewProps) => + ({ classes, closeAdvanceView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewFormProps) =>
@@ -125,7 +131,7 @@ export const SearchBarAdvancedView = compose( - setView(SearchView.BASIC)} className={classes.closeIcon}> + @@ -152,7 +158,9 @@ export const SearchBarAdvancedView = compose(