Skip to content

Commit

Permalink
feat: Add Activated Alert Rules to alert rule index (#69124)
Browse files Browse the repository at this point in the history
Duplicates the AlertRuleRow component to enable Activated Alert Rule
rows.

<img width="1418" alt="Screenshot 2024-04-17 at 11 24 44 AM"
src="https://github.com/getsentry/sentry/assets/6186377/3d07f663-84a2-412c-bc98-602b794b15cc">

Moves Alert Badge next to the rule status
Introduces a new "active state" to determine whether we are "ready to
monitor" or "actively monitoring" states
cleans up the status logic
  • Loading branch information
nhsiehgit committed Apr 18, 2024
1 parent 6d88cff commit e4303d3
Show file tree
Hide file tree
Showing 8 changed files with 604 additions and 40 deletions.
1 change: 1 addition & 0 deletions fixtures/js-stubs/metricRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export function MetricRuleFixture(
params: Partial<SavedMetricRule> = {}
): SavedMetricRule {
return {
activations: [],
status: 0,
dateCreated: '2019-07-31T23:02:02.731Z',
dataset: Dataset.ERRORS,
Expand Down
26 changes: 23 additions & 3 deletions static/app/components/badge/alertBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
import styled from '@emotion/styled';

import {DiamondStatus} from 'sentry/components/diamondStatus';
import {IconCheckmark, IconExclamation, IconFire, IconIssues} from 'sentry/icons';
import {
IconCheckmark,
IconEllipsis,
IconExclamation,
IconFire,
IconIssues,
IconShow,
} from 'sentry/icons';
import type {SVGIconProps} from 'sentry/icons/svgIcon';
import {t} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import type {ColorOrAlias} from 'sentry/utils/theme';
import {IncidentStatus} from 'sentry/views/alerts/types';
import {ActivationStatus, IncidentStatus} from 'sentry/views/alerts/types';

type Props = {
/**
* The rule is actively monitoring
*/
activationStatus?: ActivationStatus;
/**
* @deprecated use withText
*/
Expand All @@ -31,7 +42,7 @@ type Props = {
* This badge is a composition of DiamondStatus specifically used for incident
* alerts.
*/
function AlertBadge({status, withText, isIssue}: Props) {
function AlertBadge({status, withText, isIssue, activationStatus}: Props) {
let statusText = t('Resolved');
let Icon: React.ComponentType<SVGIconProps> = IconCheckmark;
let color: ColorOrAlias = 'successText';
Expand All @@ -50,6 +61,15 @@ function AlertBadge({status, withText, isIssue}: Props) {
color = 'warningText';
}

if (activationStatus === ActivationStatus.WAITING) {
statusText = t('Ready');
Icon = IconEllipsis;
color = 'purple300';
} else if (activationStatus === ActivationStatus.MONITORING) {
statusText = t('Monitoring');
Icon = IconShow;
}

return (
<Wrapper data-test-id="alert-badge">
<DiamondStatus
Expand Down
Loading

0 comments on commit e4303d3

Please sign in to comment.