X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/a94211e27f3eebaea55ccba096869f70161e74ad..c7e2cfdd8df022e558fc3a8c7cbad661c4d10126:/src/views-components/search-bar/search-bar-autocomplete-view.tsx

diff --git a/src/views-components/search-bar/search-bar-autocomplete-view.tsx b/src/views-components/search-bar/search-bar-autocomplete-view.tsx
index dd21a0f6..4dab5db0 100644
--- a/src/views-components/search-bar/search-bar-autocomplete-view.tsx
+++ b/src/views-components/search-bar/search-bar-autocomplete-view.tsx
@@ -6,23 +6,29 @@ import * as React from 'react';
 import { Paper, StyleRulesCallback, withStyles, WithStyles, List, ListItem, ListItemText } from '@material-ui/core';
 import { GroupContentsResource } from '~/services/groups-service/groups-service';
 import Highlighter from "react-highlight-words";
+import { SearchBarSelectedItem } from "~/store/search-bar/search-bar-reducer";
 
-type CssRules = 'list' | 'searchView';
+type CssRules = 'searchView' | 'list' | 'listItem';
 
 const styles: StyleRulesCallback<CssRules> = theme => {
     return {
+        searchView: {
+            borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
+        },
         list: {
             padding: 0
         },
-        searchView: {
-            borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
+        listItem: {
+            paddingLeft: theme.spacing.unit,
+            paddingRight: theme.spacing.unit * 2,
         }
     };
 };
 
 export interface SearchBarAutocompleteViewDataProps {
-    searchResults?: GroupContentsResource[];
+    searchResults: GroupContentsResource[];
     searchValue?: string;
+    selectedItem: SearchBarSelectedItem;
 }
 
 export interface SearchBarAutocompleteViewActionProps {
@@ -32,18 +38,23 @@ export interface SearchBarAutocompleteViewActionProps {
 type SearchBarAutocompleteViewProps = SearchBarAutocompleteViewDataProps & SearchBarAutocompleteViewActionProps & WithStyles<CssRules>;
 
 export const SearchBarAutocompleteView = withStyles(styles)(
-    ({ classes, searchResults, searchValue, navigateTo }: SearchBarAutocompleteViewProps) =>
-        <Paper className={classes.searchView}>
-            {searchResults && <List component="nav" className={classes.list}>
+    ({ classes, searchResults, searchValue, navigateTo, selectedItem }: SearchBarAutocompleteViewProps) => {
+        console.log(searchValue, selectedItem);
+        return <Paper className={classes.searchView}>
+            <List component="nav" className={classes.list}>
+                <ListItem button className={classes.listItem} selected={!selectedItem || searchValue === selectedItem.id}>
+                    <ListItemText secondary={searchValue}/>
+                </ListItem>
                 {searchResults.map((item: GroupContentsResource) =>
-                    <ListItem button key={item.uuid}>
-                        <ListItemText secondary={getFormattedText(item.name, searchValue)} onClick={() => navigateTo(item.uuid)} />
+                    <ListItem button key={item.uuid} className={classes.listItem} selected={item.uuid === selectedItem.id}>
+                        <ListItemText secondary={getFormattedText(item.name, searchValue)}
+                                      onClick={() => navigateTo(item.uuid)}/>
                     </ListItem>
                 )}
-            </List>}
-        </Paper>
-);
+            </List>
+        </Paper>;
+    });
 
 const getFormattedText = (textToHighlight: string, searchString = '') => {
     return <Highlighter searchWords={[searchString]} autoEscape={true} textToHighlight={textToHighlight} />;
-};
\ No newline at end of file
+};
