Fix the alerts feed (#16228)

This commit is contained in:
Aniket Katkar 2024-05-11 21:58:43 +05:30 committed by GitHub
parent 798fe311c0
commit 81720a906f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
6 changed files with 56 additions and 13 deletions

View File

@ -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 = (
<ExploreSearchCard
@ -112,7 +120,8 @@ const FeedCardBodyV1 = ({
entityFQN,
'',
'',
isExecutableTestSuite
isExecutableTestSuite,
isObservabilityAlert
)}>
{entityCard}
</Link>

View File

@ -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,
];

View File

@ -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:

View File

@ -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
),
},
];

View File

@ -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 (
<Transi18next
i18nKey="message.feed-entity-action-header"
renderElement={<Typography.Text className="font-bold" />}
values={{
entity: i18next.t(`label.${entityType}-lowercase`),
entity: i18next.t(
`label.${
entityType === EntityType.EVENT_SUBSCRIPTION
? 'alert'
: entityType
}-lowercase`
),
action: getActionLabelFromCardStyle(
cardStyle,
entityType === EntityType.APPLICATION

View File

@ -347,7 +347,8 @@ class SearchClassBase {
if (entity.fullyQualifiedName && entity.entityType) {
return getEntityLinkFromType(
entity.fullyQualifiedName,
entity.entityType as EntityType
entity.entityType as EntityType,
entity
);
}