// Copyright (C) The Arvados Authors. All rights reserved. // // SPDX-License-Identifier: AGPL-3.0 import * as React from 'react'; import { reduxForm, reset, InjectedFormProps } 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 { ArvadosTheme } from '~/common/custom-theme'; import { CloseIcon } from '~/components/icon/icon'; import { SearchBarAdvanceFormData } from '~/models/search-bar'; 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' | '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', right: '12px' }, label: { color: theme.palette.grey["500"], fontSize: '0.8125rem', alignSelf: 'center' }, buttonWrapper: { paddingRight: '14px', paddingTop: '14px', position: 'relative', }, button: { boxShadow: 'none' }, circularProgress: { position: 'absolute', top: -9, bottom: 0, left: 0, right: 0, margin: 'auto' }, searchView: { color: theme.palette.common.black, borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px` }, selectGrid: { marginBottom: theme.spacing.unit * 2 } }); interface SearchBarAdvancedViewDataProps { submitting: boolean; invalid: boolean; pristine: boolean; } interface SearchBarAdvancedViewActionProps { setView: (currentView: string) => void; saveQuery: (data: SearchBarAdvanceFormData) => void; tags: any; } type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps & InjectedFormProps & WithStyles; const validate = (values: any) => { const errors: any = {}; 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({ form: SEARCH_BAR_ADVANCE_FORM_NAME, validate, onSubmit: (data: SearchBarAdvanceFormData, dispatch: Dispatch) => { dispatch(saveQuery(data)); dispatch(reset(SEARCH_BAR_ADVANCE_FORM_NAME)); } }), withStyles(styles))( ({ classes, setView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewProps) =>
Type Cluster Project setView(SearchView.BASIC)} className={classes.closeIcon}> Date modified
{submitting && }
);