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';
19 } from '~/store/search-bar/search-bar-actions';
20 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
21 import { SearchBarAdvanceFormData } from '~/models/search-bar';
22 import { searchDataOnEnter } from '../../store/search-bar/search-bar-actions';
24 const mapStateToProps = ({ searchBar }: RootState) => {
26 searchValue: searchBar.searchValue,
27 currentView: searchBar.currentView,
28 isPopoverOpen: searchBar.open,
29 searchResults: searchBar.searchResults,
30 savedQueries: searchBar.savedQueries
34 const mapDispatchToProps = (dispatch: Dispatch) => ({
35 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
36 onSetView: (currentView: string) => dispatch(goToView(currentView)),
37 closeView: () => dispatch<any>(closeSearchView()),
38 saveRecentQuery: (query: string) => dispatch<any>(saveRecentQuery(query)),
39 loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
40 saveQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(saveQuery(data)),
41 deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
42 openSearchView: () => dispatch<any>(openSearchView()),
43 navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
44 editSavedQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(editSavedQuery(data)),
45 searchDataOnEnter: (searchValue: string) => dispatch<any>(searchDataOnEnter(searchValue))
48 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);