X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/48b31a656df71cff73bed488d8827c61b096415b..589a72bc858a9dec96f1fcecede0a0cff3e5b32a:/src/views-components/search-bar/search-bar-advanced-view.tsx

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..c658c33b 100644
--- a/src/views-components/search-bar/search-bar-advanced-view.tsx
+++ b/src/views-components/search-bar/search-bar-advanced-view.tsx
@@ -11,20 +11,20 @@ import { SEARCH_BAR_ADVANCE_FORM_NAME, saveQuery } from '~/store/search-bar/sear
 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<CssRules> = (theme: ArvadosTheme) => ({
     container: {
         padding: theme.spacing.unit * 2,
         borderBottom: `1px solid ${theme.palette.grey["200"]}`
-    }, 
+    },
     closeIcon: {
         position: 'absolute',
         top: '12px',
@@ -69,19 +69,20 @@ interface SearchBarAdvancedViewDataProps {
 interface SearchBarAdvancedViewActionProps {
     setView: (currentView: string) => void;
     saveQuery: (data: SearchBarAdvanceFormData) => void;
+    tags: any;
 }
 
-type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps 
+type SearchBarAdvancedViewProps = SearchBarAdvancedViewActionProps & SearchBarAdvancedViewDataProps
     & InjectedFormProps & WithStyles<CssRules>;
 
 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;
 };
@@ -96,7 +97,7 @@ export const SearchBarAdvancedView = compose(
         }
     }),
     withStyles(styles))(
-        ({ classes, setView, handleSubmit, submitting, invalid, pristine }: SearchBarAdvancedViewProps) =>
+        ({ classes, setView, handleSubmit, submitting, invalid, pristine, tags }: SearchBarAdvancedViewProps) =>
             <Paper className={classes.searchView}>
                 <form onSubmit={handleSubmit}>
                     <Grid container direction="column" justify="flex-start" alignItems="flex-start">
@@ -152,7 +153,8 @@ export const SearchBarAdvancedView = compose(
                             <Grid container item xs={12} justify='flex-end'>
                                 <div className={classes.buttonWrapper}>
                                     <Button type="submit" className={classes.button}
-                                        disabled={invalid || submitting || pristine}
+                                    // ToDo: create easier condition
+                                        disabled={invalid || submitting || pristine || !!(tags && tags.values && ((tags.values.key) || (tags.values.value)) && !Object.keys(tags.values).find(el => el !== 'value' && el !== 'key'))}
                                         color="primary"
                                         size='small'
                                         variant="contained">
@@ -164,5 +166,5 @@ export const SearchBarAdvancedView = compose(
                         </Grid>
                     </Grid>
                 </form>
-        </Paper>
+            </Paper>
     );
