X-Git-Url: https://git.arvados.org/arvados.git/blobdiff_plain/20cde4f6023a374d00ba401b86b60a257932683c..ef8fb604ad4a868cae8ed6ad31c1fd1520dd73e0:/src/views-components/search-bar/search-bar.tsx

diff --git a/src/views-components/search-bar/search-bar.tsx b/src/views-components/search-bar/search-bar.tsx
index 5f51654879..6a4d2a620e 100644
--- a/src/views-components/search-bar/search-bar.tsx
+++ b/src/views-components/search-bar/search-bar.tsx
@@ -3,27 +3,55 @@
 // SPDX-License-Identifier: AGPL-3.0
 
 import { connect } from 'react-redux';
-import { RootState } from '~/store/store';
+import { RootState } from 'store/store';
 import { Dispatch } from 'redux';
-import { goToView, searchBarActions } from '~/store/search-bar/search-bar-actions';
-import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
+import {
+    goToView,
+    searchData,
+    deleteSavedQuery,
+    loadRecentQueries,
+    openSearchView,
+    closeSearchView,
+    closeAdvanceView,
+    navigateToItem,
+    editSavedQuery,
+    changeData,
+    submitData, moveUp, moveDown, setAdvancedDataFromSearchValue, SEARCH_BAR_ADVANCED_FORM_NAME
+} from 'store/search-bar/search-bar-actions';
+import { SearchBarView, SearchBarActionProps, SearchBarDataProps } from 'views-components/search-bar/search-bar-view';
+import { SearchBarAdvancedFormData } from 'models/search-bar';
+import { Vocabulary } from 'models/vocabulary';
 
-const mapStateToProps = ({ searchBar }: RootState) => {
+const mapStateToProps = ({ searchBar, form }: RootState): SearchBarDataProps => {
     return {
-        // ToDo: add value to store
-        value: '',
+        searchValue: searchBar.searchValue,
         currentView: searchBar.currentView,
-        open: searchBar.open
+        isPopoverOpen: searchBar.open,
+        searchResults: searchBar.searchResults,
+        selectedItem: searchBar.selectedItem,
+        savedQueries: searchBar.savedQueries,
+        tags: form[SEARCH_BAR_ADVANCED_FORM_NAME],
+        saveQuery: form[SEARCH_BAR_ADVANCED_FORM_NAME] &&
+            form[SEARCH_BAR_ADVANCED_FORM_NAME].values &&
+            form[SEARCH_BAR_ADVANCED_FORM_NAME].values!.saveQuery
     };
 };
 
-const mapDispatchToProps = (dispatch: Dispatch) => ({
-    onSearch: (terms: string) => {
-        console.log('search: ', terms);
-    },
+const mapDispatchToProps = (dispatch: Dispatch): SearchBarActionProps => ({
+    onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch, true)),
+    onChange: (event: React.ChangeEvent<HTMLInputElement>) => dispatch<any>(changeData(event.target.value)),
     onSetView: (currentView: string) => dispatch(goToView(currentView)),
-    openView: () => dispatch<any>(searchBarActions.OPEN_SEARCH_VIEW()),
-    closeView: () => dispatch<any>(searchBarActions.CLOSE_SEARCH_VIEW())
+    onSubmit: (event: React.FormEvent<HTMLFormElement>) => dispatch<any>(submitData(event)),
+    closeView: () => dispatch<any>(closeSearchView()),
+    closeAdvanceView: () => dispatch<any>(closeAdvanceView()),
+    loadRecentQueries: () => dispatch<any>(loadRecentQueries()),
+    deleteSavedQuery: (id: number) => dispatch<any>(deleteSavedQuery(id)),
+    openSearchView: () => dispatch<any>(openSearchView()),
+    navigateTo: (uuid: string) => dispatch<any>(navigateToItem(uuid)),
+    editSavedQuery: (data: SearchBarAdvancedFormData) => dispatch<any>(editSavedQuery(data)),
+    moveUp: () => dispatch<any>(moveUp()),
+    moveDown: () => dispatch<any>(moveDown()),
+    setAdvancedDataFromSearchValue: (search: string, vocabulary: Vocabulary) => dispatch<any>(setAdvancedDataFromSearchValue(search, vocabulary))
 });
 
-export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);
\ No newline at end of file
+export const SearchBar = connect(mapStateToProps, mapDispatchToProps)(SearchBarView);
