add native select field, data text field and search bar model
[arvados.git] / src / views-components / search-bar / search-bar.tsx
index 5f51654879e5176e910451f3c1b5ac3a0be5381f..0ebee777a6b32afc4bec311f277502b7ac708939 100644 (file)
@@ -5,25 +5,38 @@
 import { connect } from 'react-redux';
 import { RootState } from '~/store/store';
 import { Dispatch } from 'redux';
-import { goToView, searchBarActions } from '~/store/search-bar/search-bar-actions';
+import {
+    goToView,
+    searchData,
+    searchBarActions,
+    deleteSavedQuery,
+    saveRecentQuery,
+    loadRecentQueries,
+    saveQuery,
+    openSearchView
+} 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) => {
     return {
-        // ToDo: add value to store
-        value: '',
+        searchValue: searchBar.searchValue,
         currentView: searchBar.currentView,
-        open: searchBar.open
+        isPopoverOpen: searchBar.open,
+        searchResults: searchBar.searchResults,
+        savedQueries: searchBar.savedQueries
     };
 };
 
 const mapDispatchToProps = (dispatch: Dispatch) => ({
-    onSearch: (terms: string) => {
-        console.log('search: ', terms);
-    },
+    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>(searchBarActions.CLOSE_SEARCH_VIEW()),
+    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())
 });
 
 export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);
\ No newline at end of file