From 81720a906ffa7dd559b7b7ca3ad18394e8d92250 Mon Sep 17 00:00:00 2001 From: Aniket Katkar Date: Sat, 11 May 2024 21:58:43 +0530 Subject: [PATCH] Fix the alerts feed (#16228) --- .../FeedCardBody/FeedCardBodyV1.tsx | 11 +++++++++- .../ui/src/constants/Feeds.constants.ts | 8 +++++++ .../ui/src/utils/EntityUtilClassBase.ts | 10 ++++++++- .../resources/ui/src/utils/EntityUtils.tsx | 22 +++++++++++++++---- .../main/resources/ui/src/utils/FeedUtils.tsx | 15 ++++++++----- .../resources/ui/src/utils/SearchClassBase.ts | 3 ++- 6 files changed, 56 insertions(+), 13 deletions(-) diff --git a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCard/FeedCardBody/FeedCardBodyV1.tsx b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCard/FeedCardBody/FeedCardBodyV1.tsx index 59b98e1fcd8..98ad27d5317 100644 --- a/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCard/FeedCardBody/FeedCardBodyV1.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/components/ActivityFeed/ActivityFeedCard/FeedCardBody/FeedCardBodyV1.tsx @@ -22,6 +22,10 @@ import RichTextEditorPreviewer from '../../../../components/common/RichTextEdito import { ASSET_CARD_STYLES } from '../../../../constants/Feeds.constants'; import { EntityType } from '../../../../enums/entity.enum'; import { CardStyle } from '../../../../generated/entity/feed/thread'; +import { + AlertType, + EventSubscription, +} from '../../../../generated/events/eventSubscription'; import { formatDateTime } from '../../../../utils/date-time/DateTimeUtils'; import entityUtilClassBase from '../../../../utils/EntityUtilClassBase'; import { @@ -92,6 +96,10 @@ const FeedCardBodyV1 = ({ const entityInfo = feed.feedInfo?.entitySpecificInfo?.entity; const isExecutableTestSuite = entityType === EntityType.TEST_SUITE && entityInfo.executable; + const isObservabilityAlert = + entityType === EntityType.EVENT_SUBSCRIPTION && + (entityInfo as EventSubscription).alertType === + AlertType.Observability; const entityCard = ( {entityCard} diff --git a/openmetadata-ui/src/main/resources/ui/src/constants/Feeds.constants.ts b/openmetadata-ui/src/main/resources/ui/src/constants/Feeds.constants.ts index 0c7fc76d4fc..2f2123808fb 100644 --- a/openmetadata-ui/src/main/resources/ui/src/constants/Feeds.constants.ts +++ b/openmetadata-ui/src/main/resources/ui/src/constants/Feeds.constants.ts @@ -11,6 +11,7 @@ * limitations under the License. */ +import { EntityType } from '../enums/entity.enum'; import { CardStyle } from '../generated/entity/feed/thread'; export const EntityRegExPattern = /<#E::([^<>]+?)::([^<>]+?)(?:::([^<>]+?))?>/; @@ -98,3 +99,10 @@ export const ASSET_CARD_STYLES = [ CardStyle.EntitySoftDeleted, CardStyle.EntityDeleted, ]; + +export const NON_DATA_ASSET_ENTITIES = [ + EntityType.TEAM, + EntityType.BOT, + EntityType.APPLICATION, + EntityType.EVENT_SUBSCRIPTION, +]; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtilClassBase.ts b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtilClassBase.ts index e27b5b442ff..bc9d7ec1c8b 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtilClassBase.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtilClassBase.ts @@ -42,6 +42,8 @@ import { getApplicationDetailsPath, getDomainDetailsPath, getIncidentManagerDetailPagePath, + getNotificationAlertDetailsPath, + getObservabilityAlertDetailsPath, getSettingPath, getTeamsWithFqnPath, } from './RouterUtils'; @@ -53,7 +55,8 @@ class EntityUtilClassBase { fullyQualifiedName: string, tab?: string, subTab?: string, - isExecutableTestSuite?: boolean + isExecutableTestSuite?: boolean, + isObservabilityAlert?: boolean ) { switch (indexType) { case SearchIndex.TOPIC: @@ -205,6 +208,11 @@ class EntityUtilClassBase { case SearchIndex.TEAM: return getTeamsWithFqnPath(fullyQualifiedName); + case EntityType.EVENT_SUBSCRIPTION: + return isObservabilityAlert + ? getObservabilityAlertDetailsPath(fullyQualifiedName) + : getNotificationAlertDetailsPath(fullyQualifiedName); + case SearchIndex.TABLE: case EntityType.TABLE: default: diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx index 08036f7ca6d..89b3fea6e8f 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/EntityUtils.tsx @@ -92,12 +92,17 @@ import { import { Topic } from '../generated/entity/data/topic'; import { DataProduct } from '../generated/entity/domains/dataProduct'; import { Team } from '../generated/entity/teams/team'; +import { + AlertType, + EventSubscription, +} from '../generated/events/eventSubscription'; import { TestCase, TestSuite } from '../generated/tests/testCase'; import { Edge, EntityLineage } from '../generated/type/entityLineage'; import { EntityReference } from '../generated/type/entityUsage'; import { TagLabel } from '../generated/type/tagLabel'; import { UsageDetails } from '../generated/type/usageDetails'; import { Votes } from '../generated/type/votes'; +import { SearchSourceAlias } from '../interface/search.interface'; import { DataQualityPageTabs } from '../pages/DataQuality/DataQualityPage.interface'; import { getOwnerValue, @@ -114,6 +119,7 @@ import { getDomainPath, getGlossaryPath, getIncidentManagerDetailPagePath, + getNotificationAlertDetailsPath, getObservabilityAlertDetailsPath, getSettingPath, getTeamsWithFqnPath, @@ -1284,7 +1290,8 @@ export const getEntityReferenceListFromEntities = < export const getEntityLinkFromType = ( fullyQualifiedName: string, - entityType: EntityType + entityType: EntityType, + entity?: SearchSourceAlias ) => { switch (entityType) { case EntityType.TABLE: @@ -1364,7 +1371,10 @@ export const getEntityLinkFromType = ( case EntityType.DOMAIN: return getDomainDetailsPath(fullyQualifiedName); case EntityType.EVENT_SUBSCRIPTION: - return getObservabilityAlertDetailsPath(fullyQualifiedName); + return (entity as EventSubscription)?.alertType === + AlertType.Observability + ? getObservabilityAlertDetailsPath(fullyQualifiedName) + : getNotificationAlertDetailsPath(fullyQualifiedName); default: return ''; } @@ -1765,13 +1775,17 @@ export const getEntityBreadcrumbs = ( return [ { name: startCase(EntityType.ALERT), - url: ROUTES.OBSERVABILITY_ALERTS, + url: + (entity as EventSubscription).alertType === AlertType.Observability + ? ROUTES.OBSERVABILITY_ALERTS + : ROUTES.NOTIFICATION_ALERTS, }, { name: entity.name, url: getEntityLinkFromType( entity.fullyQualifiedName ?? '', - (entity as SourceType).entityType as EntityType + (entity as SourceType).entityType as EntityType, + entity as SearchSourceAlias ), }, ]; diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx index bf11ed0fb14..7be650e7971 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx +++ b/openmetadata-ui/src/main/resources/ui/src/utils/FeedUtils.tsx @@ -36,6 +36,7 @@ import { hashtagRegEx, linkRegEx, mentionRegEx, + NON_DATA_ASSET_ENTITIES, teamsLinkRegEx, } from '../constants/Feeds.constants'; import { EntityType, FqnPart, TabSpecificField } from '../enums/entity.enum'; @@ -802,17 +803,19 @@ export const getFeedHeaderTextFromCardStyle = ( case CardStyle.EntityCreated: case CardStyle.EntityDeleted: case CardStyle.EntitySoftDeleted: - if ( - [EntityType.TEAM, EntityType.BOT, EntityType.APPLICATION].includes( - entityType as EntityType - ) - ) { + if (NON_DATA_ASSET_ENTITIES.includes(entityType as EntityType)) { return ( } values={{ - entity: i18next.t(`label.${entityType}-lowercase`), + entity: i18next.t( + `label.${ + entityType === EntityType.EVENT_SUBSCRIPTION + ? 'alert' + : entityType + }-lowercase` + ), action: getActionLabelFromCardStyle( cardStyle, entityType === EntityType.APPLICATION diff --git a/openmetadata-ui/src/main/resources/ui/src/utils/SearchClassBase.ts b/openmetadata-ui/src/main/resources/ui/src/utils/SearchClassBase.ts index b9efda36dbb..38ac59aacb8 100644 --- a/openmetadata-ui/src/main/resources/ui/src/utils/SearchClassBase.ts +++ b/openmetadata-ui/src/main/resources/ui/src/utils/SearchClassBase.ts @@ -347,7 +347,8 @@ class SearchClassBase { if (entity.fullyQualifiedName && entity.entityType) { return getEntityLinkFromType( entity.fullyQualifiedName, - entity.entityType as EntityType + entity.entityType as EntityType, + entity ); }