X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/aca5731485b1a79ee2305e08fd198950c7a34b42..02109725d788c1092c0b4023cee41ea901ed1a58:/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 e73db641..2541e7a3 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -47,21 +47,21 @@ export const loadRecentQueries = () => return recentSearchQueries || []; }; - // Todo: create ids for particular searchQuery +// Todo: create ids for particular searchQuery export const saveQuery = (data: SearchBarAdvanceFormData) => (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const savedSearchQueries = services.searchService.getSavedQueries(); const filteredQuery = savedSearchQueries.find(query => query.searchQuery === data.searchQuery); if (data.saveQuery && data.searchQuery) { if (filteredQuery) { - services.searchService.editSavedQueries(data); + services.searchService.editSavedQueries(data); dispatch(searchBarActions.UPDATE_SAVED_QUERY(savedSearchQueries)); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Query has been sucessfully updated', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); } else { services.searchService.saveQuery(data); dispatch(searchBarActions.SET_SAVED_QUERIES(savedSearchQueries)); dispatch(snackbarActions.OPEN_SNACKBAR({ message: 'Query has been sucessfully saved', hideDuration: 2000, kind: SnackbarKind.SUCCESS })); - } + } } dispatch(searchBarActions.SET_CURRENT_VIEW(SearchView.BASIC)); dispatch(searchBarActions.CLOSE_SEARCH_VIEW()); @@ -121,6 +121,26 @@ export const searchData = (searchValue: string) => }); dispatch(searchBarActions.SET_SEARCH_RESULTS(items)); } + if (currentView !== SearchView.AUTOCOMPLETE) { + dispatch(navigateToSearchResults); + } + + }; + +export const searchDataOnEnter = (searchValue: string) => + async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { + dispatch(searchBarActions.CLOSE_SEARCH_VIEW()); + dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue)); + dispatch(searchBarActions.SET_SEARCH_RESULTS([])); + if (searchValue) { + const filters = getFilters('name', searchValue); + const { items } = await services.groupsService.contents('', { + filters, + limit: 5, + recursive: true + }); + dispatch(searchBarActions.SET_SEARCH_RESULTS(items)); + } dispatch(navigateToSearchResults); };