X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/bf566905797e0fc73029a21457590105838326af..2f56a774af3f3401f3a1ed405a9fa70f9efa5890:/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 8abd2aa0..cfaee6d4 100644 --- a/src/views-components/search-bar/search-bar-view.tsx +++ b/src/views-components/search-bar/search-bar-view.tsx @@ -15,13 +15,13 @@ 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'; import { SearchBarAutocompleteView, SearchBarAutocompleteViewDataProps } from '~/views-components/search-bar/search-bar-autocomplete-view'; import { ArvadosTheme } from '~/common/custom-theme'; -import { SearchBarAdvanceFormData } from '~/store/search-bar/search-bar-actions'; +import { SearchBarAdvanceFormData } from '~/models/search-bar'; type CssRules = 'container' | 'containerSearchViewOpened' | 'input' | 'view'; @@ -44,7 +44,7 @@ const styles: StyleRulesCallback = (theme: ArvadosTheme) => { view: { position: 'absolute', width: '100%', - zIndex: 1001 + zIndex: 1 } }; }; @@ -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; @@ -66,6 +67,8 @@ interface SearchBarActionProps { saveQuery: (data: SearchBarAdvanceFormData) => void; deleteSavedQuery: (id: number) => void; openSearchView: () => void; + navigateTo: (uuid: string) => void; + editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => void; } type SearchBarProps = SearchBarDataProps & SearchBarActionProps & WithStyles; @@ -74,27 +77,47 @@ interface SearchBarState { value: string; } -interface RenderSavedQueriesProps { - text: string | JSX.Element; - id: number; - deleteSavedQuery: (id: number) => void; +interface RenderRecentQueriesProps { + text: string; + onSearch: (searchValue: string) => void; } -interface RenderRecentQueriesProps { +export const RenderRecentQueries = (props: RenderRecentQueriesProps) => { + return + props.onSearch(props.text)} /> + ; +}; + +interface RenderAutocompleteItemsProps { text: string | JSX.Element; + navigateTo: (uuid: string) => void; + uuid: string; } -export const RecentQueriesItem = (props: RenderRecentQueriesProps) => { +export const RenderAutocompleteItems = (props: RenderAutocompleteItemsProps) => { return - + props.navigateTo(props.uuid)} /> ; }; +interface RenderSavedQueriesProps { + text: string; + id: number; + deleteSavedQuery: (id: number) => void; + onSearch: (searchValue: string) => void; + editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => void; + data: SearchBarAdvanceFormData; +} export const RenderSavedQueries = (props: RenderSavedQueriesProps) => { return - + props.onSearch(props.text)} /> + + props.editSavedQuery(props.data, props.id)}> + + + props.deleteSavedQuery(props.id)}> @@ -116,7 +139,7 @@ export const SearchBarView = withStyles(styles)( render() { const { classes, currentView, openSearchView, closeView, isPopoverOpen } = this.props; - return closeView()}> + return
{ - const { onSetView, loadRecentQueries, savedQueries, deleteSavedQuery, searchValue, searchResults, saveQuery } = this.props; + const { onSetView, loadRecentQueries, savedQueries, deleteSavedQuery, searchValue, searchResults, saveQuery, onSearch, navigateTo, editSavedQuery } = this.props; switch (currentView) { case SearchView.BASIC: - return ; + return ; case SearchView.ADVANCED: - return ; + return ; case SearchView.AUTOCOMPLETE: return ; default: - return ; + return ; } } @@ -178,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(); }