searching on text
[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     deleteSavedQuery,
12     saveRecentQuery,
13     loadRecentQueries,
14     saveQuery,
15     openSearchView
16 } from '~/store/search-bar/search-bar-actions';
17 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
18 import { SearchBarAdvanceFormData } from '~/store/search-bar/search-bar-actions';
19 import { closeSearchView, navigateToItem } from '~/store/search-bar/search-bar-actions';
20
21 const mapStateToProps = ({ searchBar }: RootState) => {
22     return {
23         searchValue: searchBar.searchValue,
24         currentView: searchBar.currentView,
25         isPopoverOpen: searchBar.open,
26         searchResults: searchBar.searchResults,
27         savedQueries: searchBar.savedQueries
28     };
29 };
30
31 const mapDispatchToProps = (dispatch: Dispatch) => ({
32     onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
33     onSetView: (currentView: string) => dispatch(goToView(currentView)),
34     closeView: () => dispatch<any>(closeSearchView()),
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()),
40     navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid))
41 });
42
43 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);