X-Git-Url: https://git.arvados.org/arvados-workbench2.git/blobdiff_plain/519b431a41a9ab4815a1e4180ee78395b74a85de..6faff5910b3e7bdaf47ab5ede7cf8094a1b4adb9:/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 3d1b4ee9..199ec3f9 100644 --- a/src/store/search-bar/search-bar-actions.ts +++ b/src/store/search-bar/search-bar-actions.ts @@ -10,12 +10,12 @@ import { RootState } from '~/store/store'; import { initUserProject, treePickerActions } from '~/store/tree-picker/tree-picker-actions'; import { ServiceRepository } from '~/services/services'; import { FilterBuilder } from "~/services/api/filter-builder"; -import { getResourceKind, ResourceKind } from '~/models/resource'; +import { ResourceKind } from '~/models/resource'; import { GroupClass } from '~/models/group'; import { SearchView } from '~/store/search-bar/search-bar-reducer'; import { navigateTo, navigateToSearchResults } from '~/store/navigation/navigation-action'; import { snackbarActions, SnackbarKind } from '~/store/snackbar/snackbar-actions'; -import { getClusterObjectType, PropertyValues, SearchBarAdvanceFormData } from '~/models/search-bar'; +import { ClusterObjectType, PropertyValue, SearchBarAdvanceFormData } from '~/models/search-bar'; import { debounce } from 'debounce'; import * as _ from "lodash"; import { getModifiedKeysValues } from "~/common/objects"; @@ -307,7 +307,7 @@ export const parseSearchQuery: (query: string) => ParseSearchQuery = (searchValu 'has:' ]; - const hasKeywords = (search: string) => keywords.reduce((acc, keyword) => acc + search.indexOf(keyword) >= 0 ? 1 : 0, 0); + const hasKeywords = (search: string) => keywords.reduce((acc, keyword) => acc + (search.includes(keyword) ? 1 : 0), 0); let keywordsCnt = 0; const properties = {}; @@ -353,7 +353,7 @@ export const parseSearchQuery: (query: string) => ParseSearchQuery = (searchValu const getFirstProp = (sq: ParseSearchQuery, name: string) => sq.properties[name] && sq.properties[name][0]; const getPropValue = (sq: ParseSearchQuery, name: string, value: string) => sq.properties[name] && sq.properties[name].find((v: string) => v === value); -const getProperties = (sq: ParseSearchQuery): PropertyValues[] => { +const getProperties = (sq: ParseSearchQuery): PropertyValue[] => { if (sq.properties.has) { return sq.properties.has.map((value: string) => { const v = value.split(':'); @@ -371,8 +371,8 @@ export const getAdvancedDataFromQuery = (query: string): SearchBarAdvanceFormDat return { searchValue: sq.values.join(' '), - type: getResourceKind(getFirstProp(sq, 'type')), - cluster: getClusterObjectType(getFirstProp(sq, 'cluster')), + type: getFirstProp(sq, 'type') as ResourceKind, + cluster: getFirstProp(sq, 'cluster') as ClusterObjectType, projectUuid: getFirstProp(sq, 'project'), inTrash: getPropValue(sq, 'is', 'trashed') !== undefined, dateFrom: getFirstProp(sq, 'from'), @@ -387,7 +387,7 @@ export const getFilters = (filterName: string, searchValue: string): string => { const filter = new FilterBuilder(); const sq = parseSearchQuery(searchValue); - const resourceKind = getResourceKind(getFirstProp(sq, 'type')); + const resourceKind = getFirstProp(sq, 'type') as ResourceKind; let prefix = ''; switch (resourceKind) { @@ -466,12 +466,12 @@ export const initAdvanceFormProjectsTree = () => dispatch(initUserProject(SEARCH_BAR_ADVANCE_FORM_PICKER_ID)); }; -export const changeAdvanceFormProperty = (property: string, value: PropertyValues[] | string = '') => +export const changeAdvanceFormProperty = (property: string, value: PropertyValue[] | string = '') => (dispatch: Dispatch) => { dispatch(change(SEARCH_BAR_ADVANCE_FORM_NAME, property, value)); }; -export const updateAdvanceFormProperties = (propertyValues: PropertyValues) => +export const updateAdvanceFormProperties = (propertyValues: PropertyValue) => (dispatch: Dispatch) => { dispatch(arrayPush(SEARCH_BAR_ADVANCE_FORM_NAME, 'properties', propertyValues)); };