From b397e8861a08cb5f6a98de211542680d44cad5ad Mon Sep 17 00:00:00 2001 From: Dhruv Parmar <83108871+dhruvjsx@users.noreply.github.com> Date: Fri, 11 Jul 2025 12:47:30 +0530 Subject: [PATCH] Feat(ui): Add "Metric" as an Option for Entity Reference Type Dropdown (#22272) * added matric to entity reference * updated tests --- .../ui/playwright/constant/customProperty.ts | 34 +++++++------- .../ui/playwright/utils/customProperty.ts | 2 +- .../src/constants/CustomProperty.constants.ts | 5 +++ .../ui/src/utils/CustomProperty.utils.test.ts | 44 +++++++++++++++++++ 4 files changed, 67 insertions(+), 18 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts b/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts index 8f0b11b0ec9..2c9e23ce960 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/constant/customProperty.ts @@ -52,7 +52,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'containers', tableConfig: { @@ -73,7 +73,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'dashboards', tableConfig: { @@ -94,7 +94,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'databases', tableConfig: { @@ -115,7 +115,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'databaseSchemas', tableConfig: { @@ -136,7 +136,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'glossaryTerm', tableConfig: { @@ -157,7 +157,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'mlmodels', tableConfig: { @@ -178,7 +178,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'pipelines', tableConfig: { @@ -199,7 +199,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'searchIndexes', tableConfig: { @@ -220,7 +220,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'storedProcedures', tableConfig: { @@ -241,7 +241,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'tables', tableConfig: { @@ -262,7 +262,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'topics', tableConfig: { @@ -282,7 +282,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'apiCollections', tableConfig: { @@ -303,7 +303,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'apiEndpoints', tableConfig: { @@ -323,7 +323,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'dataProducts', tableConfig: { @@ -343,7 +343,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'domains', tableConfig: { @@ -363,7 +363,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'dashboardDataModels', tableConfig: { @@ -383,7 +383,7 @@ export const CUSTOM_PROPERTIES_ENTITIES = { dateFormatConfig: 'yyyy-MM-dd', dateTimeFormatConfig: 'yyyy-MM-dd HH:mm:ss', timeFormatConfig: 'HH:mm:ss', - entityReferenceConfig: ['User', 'Team'], + entityReferenceConfig: ['User', 'Team', 'Metric'], entityObj: {}, entityApiType: 'metrics', tableConfig: { diff --git a/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts b/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts index 5883998b454..822a0455114 100644 --- a/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts +++ b/openmetadata-ui/src/main/resources/ui/playwright/utils/customProperty.ts @@ -784,7 +784,7 @@ export const editCreatedProperty = async ( page.locator( `[data-row-key="${propertyName}"] [data-testid="${propertyName}-config"]` ) - ).toContainText('["user","team","table"]'); + ).toContainText('["user","team","metric","table"]'); } }; diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/CustomProperty.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/CustomProperty.constants.ts index e1e9faf795c..b9a513e54e4 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/CustomProperty.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/CustomProperty.constants.ts @@ -111,6 +111,11 @@ export const ENTITY_REFERENCE_OPTIONS = [ value: 'team', label: 'Team', }, + { + key: 'metric', + value: 'metric', + label: 'Metric', + }, ]; // supported date formats on backend diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/CustomProperty.utils.test.ts b/openmetadata-ui/src/main/resources/ui/src/utils/CustomProperty.utils.test.ts index 52d9ab09637..6a9bdafa9c1 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/CustomProperty.utils.test.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/CustomProperty.utils.test.ts @@ -14,6 +14,7 @@ import { DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_TIME_FORMAT, + ENTITY_REFERENCE_OPTIONS, SUPPORTED_DATE_TIME_FORMATS_ANTD_FORMAT_MAPPING, } from '../constants/CustomProperty.constants'; import { @@ -168,4 +169,47 @@ describe('CustomProperty.utils', () => { expect(result).toBe(expectedFormat); }); }); + + describe('Entity Reference Options', () => { + it('should have correct structure for metric option', () => { + const metricOption = ENTITY_REFERENCE_OPTIONS.find( + (option) => option.key === 'metric' + ); + + expect(metricOption).toMatchObject({ + key: 'metric', + value: 'metric', + label: 'Metric', + }); + }); + + it('should have all expected entity types including metric', () => { + const expectedEntityTypes = [ + 'table', + 'storedProcedure', + 'databaseSchema', + 'database', + 'dashboard', + 'dashboardDataModel', + 'pipeline', + 'topic', + 'container', + 'searchIndex', + 'mlmodel', + 'glossaryTerm', + 'tag', + 'user', + 'team', + 'metric', + ]; + + const actualEntityTypes = ENTITY_REFERENCE_OPTIONS.map( + (option) => option.key + ); + + expectedEntityTypes.forEach((entityType) => { + expect(actualEntityTypes).toContain(entityType); + }); + }); + }); });