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 submitData, moveUp, moveDown
20 } from '~/store/search-bar/search-bar-actions';
21 import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from '~/views-components/search-bar/search-bar-view';
22 import { SearchBarAdvanceFormData } from '~/models/search-bar';
24 const mapStateToProps = ({ searchBar, form }: RootState): SearchBarDataProps => {
26 searchValue: searchBar.searchValue,
27 currentView: searchBar.currentView,
28 isPopoverOpen: searchBar.open,
29 searchResults: searchBar.searchResults,
30 selectedItem: searchBar.selectedItem,
31 savedQueries: searchBar.savedQueries,
32 tags: form.searchBarAdvanceFormName
36 const mapDispatchToProps = (dispatch: Dispatch): SearchBarActionProps => ({
37 onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
38 onChange: (event: React.ChangeEvent<HTMLInputElement>) => dispatch<any>(changeData(event.target.value)),
39 onSetView: (currentView: string) => dispatch(goToView(currentView)),
40 onSubmit: (event: React.FormEvent<HTMLFormElement>) => dispatch<any>(submitData(event)),
41 closeView: () => dispatch<any>(closeSearchView()),
42 closeAdvanceView: () => dispatch<any>(closeAdvanceView()),
43 loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
44 deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
45 openSearchView: () => dispatch<any>(openSearchView()),
46 navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
47 editSavedQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(editSavedQuery(data)),
48 moveUp: () => dispatch<any>(moveUp()),
49 moveDown: () => dispatch<any>(moveDown())
52 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);