X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/20cde4f6023a374d00ba401b86b60a257932683c..dd315a23e98b926d4d15b9d05f1aaa1e211548a4:/src/views-components/search-bar/search-bar.tsx?ds=sidebyside diff --git a/src/views-components/search-bar/search-bar.tsx b/src/views-components/search-bar/search-bar.tsx index 5f516548..6e8ec081 100644 --- a/src/views-components/search-bar/search-bar.tsx +++ b/src/views-components/search-bar/search-bar.tsx @@ -5,25 +5,53 @@ import { connect } from 'react-redux'; import { RootState } from '~/store/store'; import { Dispatch } from 'redux'; -import { goToView, searchBarActions } from '~/store/search-bar/search-bar-actions'; -import { SearchBarView } from '~/views-components/search-bar/search-bar-view'; +import { + goToView, + searchData, + deleteSavedQuery, + loadRecentQueries, + openSearchView, + closeSearchView, + closeAdvanceView, + navigateToItem, + editSavedQuery, + changeData, + submitData, moveUp, moveDown, setAdvancedDataFromSearchValue, SEARCH_BAR_ADVANCED_FORM_NAME +} from '~/store/search-bar/search-bar-actions'; +import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from '~/views-components/search-bar/search-bar-view'; +import { SearchBarAdvancedFormData } from '~/models/search-bar'; +import { Vocabulary } from '~/models/vocabulary'; -const mapStateToProps = ({ searchBar }: RootState) => { +const mapStateToProps = ({ searchBar, form }: RootState): SearchBarDataProps => { return { - // ToDo: add value to store - value: '', + searchValue: searchBar.searchValue, currentView: searchBar.currentView, - open: searchBar.open + isPopoverOpen: searchBar.open, + searchResults: searchBar.searchResults, + selectedItem: searchBar.selectedItem, + savedQueries: searchBar.savedQueries, + tags: form[SEARCH_BAR_ADVANCED_FORM_NAME], + saveQuery: form[SEARCH_BAR_ADVANCED_FORM_NAME] && + form[SEARCH_BAR_ADVANCED_FORM_NAME].values && + form[SEARCH_BAR_ADVANCED_FORM_NAME].values!.saveQuery }; }; -const mapDispatchToProps = (dispatch: Dispatch) => ({ - onSearch: (terms: string) => { - console.log('search: ', terms); - }, +const mapDispatchToProps = (dispatch: Dispatch): SearchBarActionProps => ({ + onSearch: (valueSearch: string) => dispatch(searchData(valueSearch)), + onChange: (event: React.ChangeEvent) => dispatch(changeData(event.target.value)), onSetView: (currentView: string) => dispatch(goToView(currentView)), - openView: () => dispatch(searchBarActions.OPEN_SEARCH_VIEW()), - closeView: () => dispatch(searchBarActions.CLOSE_SEARCH_VIEW()) + onSubmit: (event: React.FormEvent) => dispatch(submitData(event)), + closeView: () => dispatch(closeSearchView()), + closeAdvanceView: () => dispatch(closeAdvanceView()), + loadRecentQueries: () => dispatch(loadRecentQueries()), + deleteSavedQuery: (id: number) => dispatch(deleteSavedQuery(id)), + openSearchView: () => dispatch(openSearchView()), + navigateTo: (uuid: string) => dispatch(navigateToItem(uuid)), + editSavedQuery: (data: SearchBarAdvancedFormData) => dispatch(editSavedQuery(data)), + moveUp: () => dispatch(moveUp()), + moveDown: () => dispatch(moveDown()), + setAdvancedDataFromSearchValue: (search: string, vocabulary: Vocabulary) => dispatch(setAdvancedDataFromSearchValue(search, vocabulary)) }); -export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView); \ No newline at end of file +export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);