From 8753ee9dbd2dcf67a9d12a9ff603a7cb97937281 Mon Sep 17 00:00:00 2001 From: Ashish Gupta Date: Wed, 18 Dec 2024 16:40:20 +0530 Subject: [PATCH] added config list in the entity ref list --- .../AdvanceSearchProvider.component.tsx | 20 ++++++--- .../src/constants/AdvancedSearch.constants.ts | 3 ++ .../ui/src/utils/AdvancedSearchClassBase.ts | 43 +++++++++---------- 3 files changed, 37 insertions(+), 29 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx b/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx index 9e7cb76f857d..c953f7e5318f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/Explore/AdvanceSearchProvider/AdvanceSearchProvider.component.tsx @@ -223,13 +223,21 @@ export const AdvanceSearchProvider = ({ Object.entries(res).forEach(([_, fields]) => { if (Array.isArray(fields) && fields.length > 0) { - fields.forEach((field: { name: string; type: string }) => { - if (field.name && field.type) { - const { subfieldsKey, dataObject } = - advancedSearchClassBase.getCustomPropertiesSubFields(field); - subfields[subfieldsKey] = dataObject; + fields.forEach( + (field: { + name: string; + type: string; + customPropertyConfig: { + config: string | string[]; + }; + }) => { + if (field.name && field.type) { + const { subfieldsKey, dataObject } = + advancedSearchClassBase.getCustomPropertiesSubFields(field); + subfields[subfieldsKey] = dataObject; + } } - }); + ); } }); } catch (error) { diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts index 800185fffd10..83240fb84ca4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/AdvancedSearch.constants.ts @@ -298,6 +298,9 @@ export const TEXT_FIELD_OPERATORS = [ 'is_null', 'is_not_null', ]; + +export const DATE_FIELD_OPERATORS = ['between', 'not_between']; + /** * Generates a query builder tree with a group containing an empty rule */ diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.ts b/openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.ts index 91d7d01ed1ec..16a5b26f457c 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/AdvancedSearchClassBase.ts @@ -22,7 +22,10 @@ import { SelectFieldSettings, } from 'react-awesome-query-builder'; import AntdConfig from 'react-awesome-query-builder/lib/config/antd'; -import { TEXT_FIELD_OPERATORS } from '../constants/AdvancedSearch.constants'; +import { + DATE_FIELD_OPERATORS, + TEXT_FIELD_OPERATORS, +} from '../constants/AdvancedSearch.constants'; import { EntityFields, SuggestionField } from '../enums/AdvancedSearch.enum'; import { SearchIndex } from '../enums/search.enum'; import { getAggregateFieldOptions } from '../rest/miscAPI'; @@ -796,42 +799,40 @@ class AdvancedSearchClassBase { }; }; - public getCustomPropertiesSubFields(field: { name: string; type: string }) { + public getCustomPropertiesSubFields(field: { + name: string; + type: string; + customPropertyConfig: { + config: string | string[]; + }; + }) { { switch (field.type) { case 'array': case 'entityReference': return { - subfieldsKey: field.name + `.fullyQualifiedName`, + subfieldsKey: field.name + `.name`, dataObject: { type: 'select', label: field.name, fieldSettings: { asyncFetch: advancedSearchClassBase.autocomplete({ - searchIndex: [SearchIndex.USER, SearchIndex.TEAM], - entityField: EntityFields.DISPLAY_NAME_KEYWORD, + searchIndex: ( + (field.customPropertyConfig.config ?? []) as string[] + ).join(',') as SearchIndex, + entityField: EntityFields.NAME_KEYWORD, }), useAsyncSearch: true, }, }, }; - case 'date-cp': { - return { - subfieldsKey: field.name, - dataObject: { - type: 'date', - valueSources: ['value'], - operators: TEXT_FIELD_OPERATORS, - }, - }; - } + case 'date-cp': case 'dateTime-cp': { return { subfieldsKey: field.name, dataObject: { - type: 'datetime', - valueSources: ['value'], - operators: TEXT_FIELD_OPERATORS, + type: 'date', + operators: DATE_FIELD_OPERATORS, }, }; } @@ -840,8 +841,7 @@ class AdvancedSearchClassBase { subfieldsKey: field.name, dataObject: { type: 'time', - valueSources: ['value'], - operators: TEXT_FIELD_OPERATORS, + operators: DATE_FIELD_OPERATORS, }, }; } @@ -851,9 +851,6 @@ class AdvancedSearchClassBase { dataObject: { type: 'text', label: field.name, - fieldSettings: { - minimum_should_match: 1, - }, }, }; }