merge checkbox
[arvados-workbench2.git] / src / views-components / search-bar / search-bar.tsx
1 // Copyright (C) The Arvados Authors. All rights reserved.
2 //
3 // SPDX-License-Identifier: AGPL-3.0
4
5 import { connect } from 'react-redux';
6 import { RootState } from '~/store/store';
7 import { Dispatch } from 'redux';
8 import {
9     goToView,
10     searchData,
11     searchBarActions,
12     deleteSavedQuery,
13     saveRecentQuery,
14     loadRecentQueries,
15     saveQuery,
16     openSearchView
17 } from '~/store/search-bar/search-bar-actions';
18 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
19
20 const mapStateToProps = ({ searchBar }: RootState) => {
21     return {
22         searchValue: searchBar.searchValue,
23         currentView: searchBar.currentView,
24         isPopoverOpen: searchBar.open,
25         searchResults: searchBar.searchResults,
26         savedQueries: searchBar.savedQueries
27     };
28 };
29
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())
39 });
40
41 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);