X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/20cde4f6023a374d00ba401b86b60a257932683c..4a055bfc98a5fc05cc311e2de1ab2213eec5497e:/src/views-components/search-bar/search-bar.tsx diff --git a/src/views-components/search-bar/search-bar.tsx b/src/views-components/search-bar/search-bar.tsx index 5f516548..41cf2916 100644 --- a/src/views-components/search-bar/search-bar.tsx +++ b/src/views-components/search-bar/search-bar.tsx @@ -5,25 +5,52 @@ 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 +} from '~/store/search-bar/search-bar-actions'; +import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from '~/views-components/search-bar/search-bar-view'; +import { SearchBarAdvanceFormData } from '~/models/search-bar'; -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.searchBarAdvanceFormName, + saveQuery: form.searchBarAdvanceFormName && + form.searchBarAdvanceFormName.values && + form.searchBarAdvanceFormName.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: SearchBarAdvanceFormData) => dispatch(editSavedQuery(data)), + moveUp: () => dispatch(moveUp()), + moveDown: () => dispatch(moveDown()), + setAdvancedDataFromSearchValue: (search: string) => dispatch(setAdvancedDataFromSearchValue(search)) }); -export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView); \ No newline at end of file +export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);