proper saving tags and disabling search button at adnveced search view
[arvados.git] / src / views-components / search-bar / search-bar.tsx
index df8808c115a3fbe5ec2fe484289aadeeb41d465c..8f39caec2801dfc6f272d01fc347ccb7b019f7e8 100644 (file)
@@ -5,23 +5,45 @@
 import { connect } from 'react-redux';
 import { RootState } from '~/store/store';
 import { Dispatch } from 'redux';
-import { goToView, searchData, searchBarActions } from '~/store/search-bar/search-bar-actions';
+import {
+    goToView,
+    searchData,
+    deleteSavedQuery,
+    saveRecentQuery,
+    loadRecentQueries,
+    saveQuery,
+    openSearchView,
+    closeSearchView,
+    navigateToItem,
+    editSavedQuery,
+    searchDataOnEnter
+} from '~/store/search-bar/search-bar-actions';
 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
+import { SearchBarAdvanceFormData } from '~/models/search-bar';
 
-const mapStateToProps = ({ searchBar }: RootState) => {
+const mapStateToProps = ({ searchBar, form }: RootState) => {
     return {
         searchValue: searchBar.searchValue,
         currentView: searchBar.currentView,
-        open: searchBar.open,
-        searchResults: searchBar.searchResults
+        isPopoverOpen: searchBar.open,
+        searchResults: searchBar.searchResults,
+        savedQueries: searchBar.savedQueries,
+        tags: form.searchBarAdvanceFormName
     };
 };
 
 const mapDispatchToProps = (dispatch: Dispatch) => ({
     onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
     onSetView: (currentView: string) => dispatch(goToView(currentView)),
-    openView: () => dispatch<any>(searchBarActions.OPEN_SEARCH_VIEW()),
-    closeView: () => dispatch<any>(searchBarActions.CLOSE_SEARCH_VIEW())
+    closeView: () => dispatch<any>(closeSearchView()),
+    saveRecentQuery: (query: string) => dispatch<any>(saveRecentQuery(query)),
+    loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
+    saveQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(saveQuery(data)),
+    deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
+    openSearchView: () => dispatch<any>(openSearchView()),
+    navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
+    editSavedQuery: (data: SearchBarAdvanceFormData) => dispatch<any>(editSavedQuery(data)),
+    searchDataOnEnter: (searchValue: string) => dispatch<any>(searchDataOnEnter(searchValue))
 });
 
 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);
\ No newline at end of file