X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/e952a4d2fac7c75375a9307f7f6676bd950bd0ed..a738a3bda2cd15740388f97488aaeb04edfd2385:/src/views-components/search-bar/search-bar-save-queries.tsx

diff --git a/src/views-components/search-bar/search-bar-save-queries.tsx b/src/views-components/search-bar/search-bar-save-queries.tsx
index ccf10a1b84..5234c214cb 100644
--- a/src/views-components/search-bar/search-bar-save-queries.tsx
+++ b/src/views-components/search-bar/search-bar-save-queries.tsx
@@ -7,6 +7,8 @@ import { withStyles, WithStyles, StyleRulesCallback, List, ListItem, ListItemTex
 import { ArvadosTheme } from '~/common/custom-theme';
 import { RemoveIcon, EditSavedQueryIcon } from '~/components/icon/icon';
 import { SearchBarAdvanceFormData } from '~/models/search-bar';
+import { SearchBarSelectedItem } from "~/store/search-bar/search-bar-reducer";
+import { getQueryFromAdvancedData } from "~/store/search-bar/search-bar-actions";
 
 type CssRules = 'root' | 'listItem' | 'listItemText' | 'button';
 
@@ -30,6 +32,7 @@ const styles: StyleRulesCallback<CssRules> = (theme: ArvadosTheme) => ({
 
 export interface SearchBarSavedQueriesDataProps {
     savedQueries: SearchBarAdvanceFormData[];
+    selectedItem: SearchBarSelectedItem;
 }
 
 export interface SearchBarSavedQueriesActionProps {
@@ -38,18 +41,18 @@ export interface SearchBarSavedQueriesActionProps {
     editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => void;
 }
 
-type SearchBarSavedQueriesProps = SearchBarSavedQueriesDataProps 
-    & SearchBarSavedQueriesActionProps 
+type SearchBarSavedQueriesProps = SearchBarSavedQueriesDataProps
+    & SearchBarSavedQueriesActionProps
     & WithStyles<CssRules>;
 
 export const SearchBarSavedQueries = withStyles(styles)(
-    ({ classes, savedQueries, onSearch, editSavedQuery, deleteSavedQuery }: SearchBarSavedQueriesProps) =>
+    ({ classes, savedQueries, onSearch, editSavedQuery, deleteSavedQuery, selectedItem }: SearchBarSavedQueriesProps) =>
         <List component="nav" className={classes.root}>
-            {savedQueries.map((query, index) => 
-                <ListItem button key={index} className={classes.listItem}>
-                    <ListItemText disableTypography 
-                        secondary={query.searchQuery} 
-                        onClick={() => onSearch(query.searchQuery)} 
+            {savedQueries.map((query, index) =>
+                <ListItem button key={index} className={classes.listItem} selected={`SQ-${index}-${query.queryName}` === selectedItem.id}>
+                    <ListItemText disableTypography
+                        secondary={query.queryName}
+                        onClick={() => onSearch(getQueryFromAdvancedData(query))}
                         className={classes.listItemText} />
                     <ListItemSecondaryAction>
                         <Tooltip title="Edit">
@@ -65,4 +68,4 @@ export const SearchBarSavedQueries = withStyles(styles)(
                     </ListItemSecondaryAction>
                 </ListItem>
             )}
-    </List>);
\ No newline at end of file
+    </List>);
