add closeSearchView for search bar actions
authorJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 15 Oct 2018 08:08:15 +0000 (10:08 +0200)
committerJanicki Artur <artur.janicki@contractors.roche.com>
Mon, 15 Oct 2018 08:08:15 +0000 (10:08 +0200)
Feature #13827

Arvados-DCO-1.1-Signed-off-by: Janicki Artur <artur.janicki@contractors.roche.com>

src/store/search-bar/search-bar-actions.ts
src/views-components/search-bar/search-bar.tsx

index 40528d215e56b3fb310971121a9a12125735b651..f7527852ada8f71dd7e9dc2fa1ba559774049513 100644 (file)
@@ -61,6 +61,14 @@ export const openSearchView = () =>
         dispatch(searchBarActions.SET_SAVED_QUERIES(savedSearchQueries));
     };
 
+export const closeSearchView = () => 
+    (dispatch: Dispatch<any>, getState: () => RootState, services: ServiceRepository) => {
+        const isOpen = getState().searchBar.open;
+        if(isOpen) {
+            dispatch(searchBarActions.CLOSE_SEARCH_VIEW());
+        }
+    };
+
 
 export const searchData = (searchValue: string) =>
     async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => {
index 0ebee777a6b32afc4bec311f277502b7ac708939..d6561c591b770f15c63144120b86549044076ca0 100644 (file)
@@ -8,12 +8,12 @@ import { Dispatch } from 'redux';
 import {
     goToView,
     searchData,
-    searchBarActions,
     deleteSavedQuery,
     saveRecentQuery,
     loadRecentQueries,
     saveQuery,
-    openSearchView
+    openSearchView,
+    closeSearchView
 } from '~/store/search-bar/search-bar-actions';
 import { SearchBarView } from '~/views-components/search-bar/search-bar-view';
 import { SearchBarAdvanceFormData } from '~/models/search-bar';
@@ -31,7 +31,7 @@ const mapStateToProps = ({ searchBar }: RootState) => {
 const mapDispatchToProps = (dispatch: Dispatch) => ({
     onSearch: (valueSearch: string) => dispatch<any>(searchData(valueSearch)),
     onSetView: (currentView: string) => dispatch(goToView(currentView)),
-    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)),