X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/0ffeba19321b0a7f033785651778f67aef057d4c..ba9a587ab628caea44d923b34d285a29e83e3456:/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 088c9257..165392c6 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -61,7 +61,7 @@ export const searchData = (searchValue: string) => const currentView = getState().searchBar.currentView; dispatch(searchBarActions.SET_SEARCH_VALUE(searchValue)); if (searchValue.length > 0) { - dispatch(searchGroups(searchValue)); + dispatch(searchGroups(searchValue, 5, {})); if (currentView === SearchView.BASIC) { dispatch(searchBarActions.CLOSE_SEARCH_VIEW()); dispatch(navigateToSearchResults); @@ -176,12 +176,12 @@ const startSearch = () => dispatch(searchData(searchValue)); }; -const searchGroups = (searchValue: string, limit = 5, resourceKind?: ResourceKind) => +const searchGroups = (searchValue: string, limit: number, {...props}) => async (dispatch: Dispatch, getState: () => RootState, services: ServiceRepository) => { const currentView = getState().searchBar.currentView; if (searchValue || currentView === SearchView.ADVANCED) { - const filters = getFilters('name', searchValue, resourceKind); + const filters = getFilters('name', searchValue, props); const { items } = await services.groupsService.contents('', { filters, limit, @@ -191,12 +191,15 @@ const searchGroups = (searchValue: string, limit = 5, resourceKind?: ResourceKin } }; -export const getFilters = (filterName: string, searchValue: string, resourceKind?: ResourceKind): string => { +export const getFilters = (filterName: string, searchValue: string, props: any): string => { + const { resourceKind, dateTo, dateFrom } = props; return new FilterBuilder() .addIsA("uuid", buildUuidFilter(resourceKind)) .addILike(filterName, searchValue, GroupContentsResourcePrefix.COLLECTION) .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROCESS) .addILike(filterName, searchValue, GroupContentsResourcePrefix.PROJECT) + .addLte('modified_at', buildDateFilter(dateTo)) + .addGte('modified_at', buildDateFilter(dateFrom)) .addEqual('groupClass', GroupClass.PROJECT, GroupContentsResourcePrefix.PROJECT) .getFilters(); }; @@ -205,6 +208,10 @@ const buildUuidFilter = (type?: ResourceKind): ResourceKind[] => { return type ? [type] : [ResourceKind.PROJECT, ResourceKind.COLLECTION, ResourceKind.PROCESS]; }; +const buildDateFilter = (date?: string): string => { + return date ? date : ''; +}; + export const initAdvanceFormProjectsTree = () => (dispatch: Dispatch) => { dispatch(initUserProject(SEARCH_BAR_ADVANCE_FORM_PICKER_ID));