/* * Copyright OpenSearch Contributors * SPDX-License-Identifier: Apache-2.0 */ import { EuiAccordion, EuiHorizontalRule, EuiLink, EuiSpacer, EuiText, EuiTitle, } from '@elastic/eui'; import { AlertCondition } from '../../../../../models/interfaces'; import React from 'react'; import { createTextDetailsGroup } from '../../../../utils/helpers'; import { parseAlertSeverityToOption } from '../../../CreateDetector/components/ConfigureAlerts/utils/helpers'; import { DEFAULT_EMPTY_DATA, getNotificationDetailsHref } from '../../../../utils/constants'; import { FeatureChannelList, RuleInfo } from '../../../../../server/models/interfaces'; import { Detector } from '../../../../../types'; export interface AlertTriggerViewProps { alertTrigger: AlertCondition; orderPosition: number; detector: Detector; notificationChannels: FeatureChannelList[]; rules: { [key: string]: RuleInfo }; } export const AlertTriggerView: React.FC = ({ alertTrigger, orderPosition, detector, notificationChannels, rules, }) => { const { name, sev_levels, types, tags, ids, severity, actions } = alertTrigger; const alertSeverity = parseAlertSeverityToOption(severity)?.label || DEFAULT_EMPTY_DATA; const action = actions[0]; const notificationChannelId = detector.triggers[orderPosition].actions[0].destination_id; const notificationChannel = notificationChannels.find( (channel) => channel.config_id === notificationChannelId ); const conditionRuleNames = ids.map((ruleId) => rules[ruleId]?._source.title); return (
{orderPosition > 0 && } {orderPosition === 0 && }

{name}

} > {createTextDetailsGroup([{ label: 'Trigger name', content: `${name}` }])}
If any detection rule matches
{createTextDetailsGroup([ { label: 'Log type', content: `${types[0]}` || DEFAULT_EMPTY_DATA }, { label: 'Rule names', content: conditionRuleNames.join('\n') || DEFAULT_EMPTY_DATA }, ])} {createTextDetailsGroup([ { label: 'Rule severities', content: sev_levels.join('\n') || DEFAULT_EMPTY_DATA }, { label: 'Tags', content: tags.join('\n') || DEFAULT_EMPTY_DATA }, ])}
Alert and notify
{createTextDetailsGroup([ { label: 'Trigger alerts with severity', content: `${alertSeverity}` || DEFAULT_EMPTY_DATA, }, ])} {createTextDetailsGroup([ { label: 'Notify channel', content: notificationChannel ? ( {notificationChannel.name} ) : ( {DEFAULT_EMPTY_DATA} ), }, ])}
); };