X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/2cfb56ef5060cbad461062690fad650f15c49731..48b31a656df71cff73bed488d8827c61b096415b:/src/views-components/search-bar/search-bar-view.tsx

diff --git a/src/views-components/search-bar/search-bar-view.tsx b/src/views-components/search-bar/search-bar-view.tsx
index 8e1f84b01f..cfaee6d4f3 100644
--- a/src/views-components/search-bar/search-bar-view.tsx
+++ b/src/views-components/search-bar/search-bar-view.tsx
@@ -15,7 +15,7 @@ import {
     ClickAwayListener
 } from '@material-ui/core';
 import SearchIcon from '@material-ui/icons/Search';
-import { RemoveIcon } from '~/components/icon/icon';
+import { RemoveIcon, EditSavedQueryIcon } from '~/components/icon/icon';
 import { SearchView } from '~/store/search-bar/search-bar-reducer';
 import { SearchBarBasicView } from '~/views-components/search-bar/search-bar-basic-view';
 import { SearchBarAdvancedView } from '~/views-components/search-bar/search-bar-advanced-view';
@@ -53,11 +53,12 @@ type SearchBarDataProps = {
     searchValue: string;
     currentView: string;
     isPopoverOpen: boolean;
-    savedQueries: string[];
+    savedQueries: SearchBarAdvanceFormData[];
 } & SearchBarAutocompleteViewDataProps;
 
 interface SearchBarActionProps {
     onSearch: (value: string) => any;
+    searchDataOnEnter: (value: string) => void;
     debounce?: number;
     onSetView: (currentView: string) => void;
     closeView: () => void;
@@ -67,6 +68,7 @@ interface SearchBarActionProps {
     deleteSavedQuery: (id: number) => void;
     openSearchView: () => void;
     navigateTo: (uuid: string) => void;
+    editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => void;
 }
 
 type SearchBarProps = SearchBarDataProps & SearchBarActionProps & WithStyles<CssRules>;
@@ -75,11 +77,9 @@ interface SearchBarState {
     value: string;
 }
 
-
-
 interface RenderRecentQueriesProps {
-    text: string | JSX.Element;
-    onSearch: (searchValue: string | JSX.Element) => void;
+    text: string;
+    onSearch: (searchValue: string) => void;
 }
 
 export const RenderRecentQueries = (props: RenderRecentQueriesProps) => {
@@ -101,16 +101,23 @@ export const RenderAutocompleteItems = (props: RenderAutocompleteItemsProps) =>
 };
 
 interface RenderSavedQueriesProps {
-    text: string | JSX.Element;
+    text: string;
     id: number;
     deleteSavedQuery: (id: number) => void;
-    onSearch: (searchValue: string | JSX.Element) => void;
+    onSearch: (searchValue: string) => void;
+    editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => void;
+    data: SearchBarAdvanceFormData;
 }
 
 export const RenderSavedQueries = (props: RenderSavedQueriesProps) => {
     return <ListItem button>
         <ListItemText secondary={props.text} onClick={() => props.onSearch(props.text)} />
         <ListItemSecondaryAction>
+            <Tooltip title="Edit">
+                <IconButton aria-label="Edit" onClick={() => props.editSavedQuery(props.data, props.id)}>
+                    <EditSavedQueryIcon />
+                </IconButton>
+            </Tooltip>
             <Tooltip title="Remove">
                 <IconButton aria-label="Remove" onClick={() => props.deleteSavedQuery(props.id)}>
                     <RemoveIcon />
@@ -175,10 +182,10 @@ export const SearchBarView = withStyles(styles)(
         }
 
         getView = (currentView: string) => {
-            const { onSetView, loadRecentQueries, savedQueries, deleteSavedQuery, searchValue, searchResults, saveQuery, onSearch, navigateTo } = this.props;
+            const { onSetView, loadRecentQueries, savedQueries, deleteSavedQuery, searchValue, searchResults, saveQuery, onSearch, navigateTo, editSavedQuery } = this.props;
             switch (currentView) {
                 case SearchView.BASIC:
-                    return <SearchBarBasicView setView={onSetView} recentQueries={loadRecentQueries} savedQueries={savedQueries} deleteSavedQuery={deleteSavedQuery} onSearch={onSearch} />;
+                    return <SearchBarBasicView setView={onSetView} recentQueries={loadRecentQueries} savedQueries={savedQueries} deleteSavedQuery={deleteSavedQuery} onSearch={onSearch} editSavedQuery={editSavedQuery} />;
                 case SearchView.ADVANCED:
                     return <SearchBarAdvancedView setView={onSetView} saveQuery={saveQuery} />;
                 case SearchView.AUTOCOMPLETE:
@@ -187,7 +194,7 @@ export const SearchBarView = withStyles(styles)(
                         searchResults={searchResults}
                         searchValue={searchValue} />;
                 default:
-                    return <SearchBarBasicView setView={onSetView} recentQueries={loadRecentQueries} savedQueries={savedQueries} deleteSavedQuery={deleteSavedQuery} onSearch={onSearch} />;
+                    return <SearchBarBasicView setView={onSetView} recentQueries={loadRecentQueries} savedQueries={savedQueries} deleteSavedQuery={deleteSavedQuery} onSearch={onSearch} editSavedQuery={editSavedQuery} />;
             }
         }
 
@@ -195,7 +202,7 @@ export const SearchBarView = withStyles(styles)(
             event.preventDefault();
             clearTimeout(this.timeout);
             this.props.saveRecentQuery(this.state.value);
-            this.props.onSearch(this.state.value);
+            this.props.searchDataOnEnter(this.state.value);
             this.props.loadRecentQueries();
         }
 
