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';
19 import { SearchBarAdvanceFormData } from '~/store/search-bar/search-bar-actions';
21 const mapStateToProps = ({ searchBar }: RootState) => {
23 searchValue: searchBar.searchValue,
24 currentView: searchBar.currentView,
25 isPopoverOpen: searchBar.open,
26 searchResults: searchBar.searchResults,
27 savedQueries: searchBar.savedQueries
31 const mapDispatchToProps = (dispatch: Dispatch) => ({
32 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
33 onSetView: (currentView: string) => dispatch(goToView(currentView)),
34 closeView: () => dispatch<any>(searchBarActions.CLOSE_SEARCH_VIEW()),
35 saveRecentQuery: (query: string) => dispatch<any>(saveRecentQuery(query)),
36 loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
37 saveQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(saveQuery(data)),
38 deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
39 openSearchView: () => dispatch<any>(openSearchView())
42 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);