X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/956da0a3141be31119f6310734a59f4b79c254e3..2cfb56ef5060cbad461062690fad650f15c49731:/src/store/search-bar/search-bar-actions.ts diff --git a/src/store/search-bar/search-bar-actions.ts b/src/store/search-bar/search-bar-actions.ts index 394920a5..771cbc89 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -13,6 +13,7 @@ import { GroupClass } from '~/models/group'; import { SearchView } from '~/store/search-bar/search-bar-reducer'; import { navigateToSearchResults, navigateTo } from '~/store/navigation/navigation-action'; import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; +import { SearchBarAdvanceFormData } from '~/models/search-bar'; export const searchBarActions = unionize({ SET_CURRENT_VIEW: ofType(), @@ -25,17 +26,6 @@ export const searchBarActions = unionize({ export type SearchBarActions = UnionOf; -export interface SearchBarAdvanceFormData { - type?: GroupContentsResource; - cluster?: string; - project?: string; - inTrash: boolean; - dataFrom: string; - dataTo: string; - saveQuery: boolean; - searchQuery: string; -} - export const SEARCH_BAR_ADVANCE_FORM_NAME = 'searchBarAdvanceFormName'; export const goToView = (currentView: string) => searchBarActions.SET_CURRENT_VIEW(currentView); @@ -75,12 +65,16 @@ export const openSearchView = () => dispatch(searchBarActions.SET_SAVED_QUERIES(savedSearchQueries)); }; -export const closeSearchView = () => +export const closeSearchView = () => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { - dispatch(searchBarActions.CLOSE_SEARCH_VIEW()); - dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC)); + const isOpen = getState().searchBar.open; + if(isOpen) { + dispatch(searchBarActions.CLOSE_SEARCH_VIEW()); + dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC)); + } }; + export const navigateToItem = (uuid: string) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { dispatch(searchBarActions.CLOSE_SEARCH_VIEW());