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';
17 } from '~/store/search-bar/search-bar-actions';
18 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
20 const mapStateToProps = ({ searchBar }: RootState) => {
22 searchValue: searchBar.searchValue,
23 currentView: searchBar.currentView,
24 isPopoverOpen: searchBar.open,
25 searchResults: searchBar.searchResults,
26 savedQueries: searchBar.savedQueries
30 const mapDispatchToProps = (dispatch: Dispatch) => ({
31 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
32 onSetView: (currentView: string) => dispatch(goToView(currentView)),
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)),
38 openSearchView: () => dispatch<any>(openSearchView())
41 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);