import React from 'react' import cn from 'classnames'; import stl from './alertItem.module.css'; import AlertTypeLabel from './AlertTypeLabel'; const AlertItem = props => { const { alert, onEdit, active } = props; const getThreshold = threshold => { if (threshold === 15) return '15 Minutes'; if (threshold === 30) return '30 Minutes'; if (threshold === 60) return '1 Hour'; if (threshold === 120) return '2 Hours'; if (threshold === 240) return '4 Hours'; if (threshold === 1440) return '1 Day'; } const getNotifyChannel = alert => { let str = ''; if (alert.slack) str = 'Slack'; if (alert.email) str += (str === '' ? '' : ' and ')+ 'Email'; if (alert.webhool) str += (str === '' ? '' : ' and ')+ 'Webhook'; if (str === '') return 'OpenReplay'; return str; } const isThreshold = alert.detectionMethod === 'threshold'; return (
{alert.name}
{alert.detectionMethod === 'threshold' && (
When {alert.metric.text} is {alert.condition.text} {alert.query.right} {alert.metric.unit} over the past {getThreshold(alert.currentPeriod)}, notify me on {getNotifyChannel(alert)}.
)} {alert.detectionMethod === 'change' && (
When the {alert.options.change} of {alert.metric.text} is {alert.condition.text} {alert.query.right} {alert.metric.unit} over the past {getThreshold(alert.currentPeriod)} compared to the previous {getThreshold(alert.previousPeriod)}, notify me on {getNotifyChannel(alert)}.
)}
) } export default AlertItem