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';
23 const mapStateToProps = ({ searchBar }: RootState) => {
25 searchValue: searchBar.searchValue,
26 currentView: searchBar.currentView,
27 isPopoverOpen: searchBar.open,
28 searchResults: searchBar.searchResults,
29 savedQueries: searchBar.savedQueries
33 const mapDispatchToProps = (dispatch: Dispatch) => ({
34 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
35 onSetView: (currentView: string) => dispatch(goToView(currentView)),
36 closeView: () => dispatch<any>(closeSearchView()),
37 saveRecentQuery: (query: string) => dispatch<any>(saveRecentQuery(query)),
38 loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
39 saveQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(saveQuery(data)),
40 deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
41 openSearchView: () => dispatch<any>(openSearchView()),
42 navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
43 editSavedQuery: (data: SearchBarAdvanceFormData, id: number) => dispatch<any>(editSavedQuery(data, id))
46 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);