utils.tsx 693 B

1234567891011121314151617181920212223
  1. import type {Actor} from 'sentry/types/core';
  2. import {
  3. type CombinedAlerts,
  4. CombinedAlertType,
  5. type CombinedMetricIssueAlerts,
  6. IncidentStatus,
  7. } from 'sentry/views/alerts/types';
  8. export function hasActiveIncident(rule: CombinedMetricIssueAlerts): boolean {
  9. return (
  10. rule.latestIncident?.status !== undefined &&
  11. [IncidentStatus.CRITICAL, IncidentStatus.WARNING].includes(rule.latestIncident.status)
  12. );
  13. }
  14. export function getActor(rule: CombinedAlerts): Actor | null {
  15. if (rule.type === CombinedAlertType.UPTIME) {
  16. return rule.owner;
  17. }
  18. const ownerId = rule.owner?.split(':')[1];
  19. return ownerId ? {type: 'team' as Actor['type'], id: ownerId, name: ''} : null;
  20. }