X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/8775768ca3a344775c81b7278a50d56d9be3f9b6..8f42eae95848318db3f09a4424424560d36f2edd:/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 64b836196b..48172424ce 100644
--- a/src/views-components/search-bar/search-bar-autocomplete-view.tsx
+++ b/src/views-components/search-bar/search-bar-autocomplete-view.tsx
@@ -4,26 +4,42 @@
 
 import * as React from 'react';
 import { Paper, StyleRulesCallback, withStyles, WithStyles, List } from '@material-ui/core';
-import { RenderRecentQueries } from '~/views-components/search-bar/search-bar-view';
+import { RenderAutocompleteItems } from '~/views-components/search-bar/search-bar-view';
+import { GroupContentsResource } from '~/services/groups-service/groups-service';
+import Highlighter from "react-highlight-words";
 
-type CssRules = 'list';
+type CssRules = 'list' | 'searchView';
 
 const styles: StyleRulesCallback<CssRules> = theme => {
     return {
         list: {
-            padding: '0px'
+            padding: 0
+        },
+        searchView: {
+            borderRadius: `0 0 ${theme.spacing.unit / 2}px ${theme.spacing.unit / 2}px`
         }
     };
 };
 
-interface SearchBarAutocompleteViewProps {
+export interface SearchBarAutocompleteViewDataProps {
+    searchResults?: GroupContentsResource[];
+    searchValue?: string;
+    navigateTo: (uuid: string) => void;
 }
 
+type SearchBarAutocompleteViewProps = SearchBarAutocompleteViewDataProps & WithStyles<CssRules>;
+
 export const SearchBarAutocompleteView = withStyles(styles)(
-    ({ classes }: SearchBarAutocompleteViewProps & WithStyles<CssRules>) =>
-        <Paper>
-            <List component="nav" className={classes.list}>
-                <RenderRecentQueries text='AUTOCOMPLETE VIEW' />
-            </List>
+    ({ classes, searchResults, searchValue, navigateTo }: SearchBarAutocompleteViewProps) =>
+        <Paper className={classes.searchView}>
+            {searchResults && <List component="nav" className={classes.list}>
+                {searchResults.map((item: GroupContentsResource) => {
+                    return <RenderAutocompleteItems key={item.uuid} text={getFormattedText(item.name, searchValue)} navigateTo={navigateTo} uuid={item.uuid} />;
+                })}
+            </List>}
         </Paper>
-);
\ No newline at end of file
+);
+
+const getFormattedText = (textToHighlight: string, searchString = '') => {
+    return <Highlighter searchWords={[searchString]} autoEscape={true} textToHighlight={textToHighlight} />;
+};
\ No newline at end of file
