1 // Copyright (C) The Arvados Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
5 import { connect } from 'react-redux';
6 import { RootState } from '~/store/store';
7 import { Dispatch } from 'redux';
16 } from '~/store/search-bar/search-bar-actions';
17 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
19 const mapStateToProps = ({ searchBar }: RootState) => {
21 searchValue: searchBar.searchValue,
22 currentView: searchBar.currentView,
23 isPopoverOpen: searchBar.open,
24 searchResults: searchBar.searchResults,
25 savedQueries: searchBar.savedQueries
29 const mapDispatchToProps = (dispatch: Dispatch) => ({
30 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
31 onSetView: (currentView: string) => dispatch(goToView(currentView)),
32 openView: () => dispatch<any>(searchBarActions.OPEN_SEARCH_VIEW()),
33 closeView: () => dispatch<any>(searchBarActions.CLOSE_SEARCH_VIEW()),
34 saveRecentQuery: (query: string) => dispatch<any>(saveRecentQuery(query)),
35 loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
36 saveQuery: (query: string) => dispatch<any>(saveQuery(query)),
37 deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id))
40 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);