Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(alerts): Remove more activated alerts fe code #83066

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 3 additions & 23 deletions static/app/components/badge/alertBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,14 @@
import styled from '@emotion/styled';

import {DiamondStatus} from 'sentry/components/diamondStatus';
import {
IconCheckmark,
IconEllipsis,
IconExclamation,
IconFire,
IconIssues,
IconShow,
} from 'sentry/icons';
import {IconCheckmark, IconExclamation, IconFire, IconIssues} 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 {ActivationStatus, IncidentStatus} from 'sentry/views/alerts/types';
import {IncidentStatus} from 'sentry/views/alerts/types';

type Props = {
/**
* The rule is actively monitoring
*/
activationStatus?: ActivationStatus;
/**
* @deprecated use withText
*/
Expand All @@ -42,7 +31,7 @@ type Props = {
* This badge is a composition of DiamondStatus specifically used for incident
* alerts.
*/
function AlertBadge({status, withText, isIssue, activationStatus}: Props) {
function AlertBadge({status, withText, isIssue}: Props) {
let statusText = t('Resolved');
let Icon: React.ComponentType<SVGIconProps> = IconCheckmark;
let color: ColorOrAlias = 'successText';
Expand All @@ -61,15 +50,6 @@ function AlertBadge({status, withText, isIssue, activationStatus}: 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
34 changes: 0 additions & 34 deletions static/app/types/alerts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -310,37 +310,3 @@ export enum RuleActionsCategories {
SOME_DEFAULT = 'some_default',
NO_DEFAULT = 'no_default',
}

export enum MonitorType {
CONTINUOUS = 0,
ACTIVATED = 1,
}

export enum ActivationConditionType {
RELEASE_CREATION = 0,
DEPLOY_CREATION = 1,
}

export type AlertRuleActivation = {
activator: string;
alertRuleId: string;
conditionType: string;
dateCreated: string;
finishedAt: string;
id: string;
isComplete: boolean;
querySubscriptionId: string;
metricValue?: number;
};

export enum ActivationTrigger {
ACTIVATED = 'activated',
FINISHED = 'finished',
}

export type ActivationTriggerActivity = {
activator: string;
conditionType: string;
dateCreated: string;
type: ActivationTrigger;
};
102 changes: 0 additions & 102 deletions static/app/views/alerts/list/rules/alertRulesList.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -386,61 +386,6 @@ describe('AlertRulesList', () => {
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
});

it('displays activated metric alert status', async () => {
rulesMock = MockApiClient.addMockResponse({
url: '/organizations/org-slug/combined-rules/',
headers: {Link: pageLinks},
body: [
{
...MetricRuleFixture({
id: '1',
projects: ['earth'],
name: 'Active Activated Alert',
monitorType: 1,
activationCondition: 0,
activations: [
{
alertRuleId: '1',
dateCreated: '2021-08-01T00:00:00Z',
finishedAt: '',
id: '1',
isComplete: false,
querySubscriptionId: '1',
activator: '123',
conditionType: '0',
},
],
latestIncident: IncidentFixture({
status: IncidentStatus.CRITICAL,
}),
}),
type: CombinedAlertType.METRIC,
},
{
...MetricRuleFixture({
id: '2',
projects: ['earth'],
name: 'Ready Activated Alert',
monitorType: 1,
activationCondition: 0,
}),
type: CombinedAlertType.METRIC,
},
],
});
const {router, organization} = initializeOrg({organization: defaultOrg});
render(<AlertRulesList />, {router, organization});

expect(await screen.findByText('Active Activated Alert')).toBeInTheDocument();
expect(await screen.findByText('Ready Activated Alert')).toBeInTheDocument();

expect(screen.getByText('Last activated')).toBeInTheDocument();
expect(screen.getByText('Alert has not been activated yet')).toBeInTheDocument();
expect(screen.getByText('Above 70')).toBeInTheDocument(); // the fixture trigger threshold
expect(screen.getByText('Below 70')).toBeInTheDocument(); // Alert has never fired, so no resolved threshold
expect(screen.getAllByTestId('alert-badge')[0]).toBeInTheDocument();
});

it('displays issue alert disabled', async () => {
MockApiClient.addMockResponse({
url: '/organizations/org-slug/combined-rules/',
Expand Down Expand Up @@ -564,53 +509,6 @@ describe('AlertRulesList', () => {
);
});

it('renders ACTIVATED Metric Alerts', async () => {
rulesMock = MockApiClient.addMockResponse({
url: '/organizations/org-slug/combined-rules/',
headers: {Link: pageLinks},
body: [
{
...ProjectAlertRuleFixture({
id: '123',
name: 'First Issue Alert',
projects: ['earth'],
createdBy: {name: 'Samwise', id: 1, email: ''},
}),
type: CombinedAlertType.ISSUE,
},
{
...MetricRuleFixture({
id: '345',
projects: ['earth'],
name: 'activated Test Metric Alert',
monitorType: 1,
latestIncident: IncidentFixture({
status: IncidentStatus.CRITICAL,
}),
}),
type: CombinedAlertType.METRIC,
},
{
...MetricRuleFixture({
id: '678',
name: 'Test Metric Alert 2',
monitorType: 0,
projects: ['earth'],
latestIncident: null,
}),
type: CombinedAlertType.METRIC,
},
],
});

const {router, organization} = initializeOrg({organization: defaultOrg});
render(<AlertRulesList />, {router, organization});

expect(await screen.findByText('Test Metric Alert 2')).toBeInTheDocument();
expect(await screen.findByText('First Issue Alert')).toBeInTheDocument();
expect(await screen.findByText('activated Test Metric Alert')).toBeInTheDocument();
});

it('renders uptime alert rules', async () => {
rulesMock = MockApiClient.addMockResponse({
url: '/organizations/org-slug/combined-rules/',
Expand Down
36 changes: 0 additions & 36 deletions static/app/views/alerts/list/rules/combinedAlertBadge.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,48 +1,12 @@
import {MetricRuleFixture} from 'sentry-fixture/metricRule';
import {MetricRuleActivationFixture} from 'sentry-fixture/metricRuleActivation';
import {ProjectAlertRuleFixture} from 'sentry-fixture/projectAlertRule';

import {render, screen, userEvent} from 'sentry-test/reactTestingLibrary';

import {MonitorType} from 'sentry/types/alerts';
import CombinedAlertBadge from 'sentry/views/alerts/list/rules/combinedAlertBadge';
import {CombinedAlertType} from 'sentry/views/alerts/types';

describe('CombinedAlertBadge', function () {
it('Renders correctly for waiting metric alert rules', async function () {
const rule = {
...MetricRuleFixture({monitorType: MonitorType.ACTIVATED}),
// Cast here to inform typescript that this will always be a metric type rule
type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
};

render(<CombinedAlertBadge rule={rule} />);

await userEvent.hover(screen.getByTestId('alert-badge'));

// Renders tooltip with correct text
expect(
await screen.findByText('Metric Alert Status: Ready to monitor')
).toBeInTheDocument();
});

it('Renders correctly for monitoring metric alert rules', async function () {
const rule = {
...MetricRuleFixture({monitorType: MonitorType.ACTIVATED}),
activations: [MetricRuleActivationFixture()],
type: CombinedAlertType.METRIC as CombinedAlertType.METRIC,
};

render(<CombinedAlertBadge rule={rule} />);

await userEvent.hover(screen.getByTestId('alert-badge'));

// Renders tooltip with correct text
expect(
await screen.findByText('Metric Alert Status: Monitoring')
).toBeInTheDocument();
});

it('Renders correctly for metric alert rules', async function () {
const rule = {
...MetricRuleFixture(),
Expand Down
24 changes: 0 additions & 24 deletions static/app/views/alerts/list/rules/combinedAlertBadge.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import AlertBadge from 'sentry/components/badge/alertBadge';
import {Tooltip} from 'sentry/components/tooltip';
import {t, tct} from 'sentry/locale';
import {MonitorType} from 'sentry/types/alerts';
import {UptimeMonitorStatus} from 'sentry/views/alerts/rules/uptime/types';
import {
ActivationStatus,
type CombinedAlerts,
CombinedAlertType,
IncidentStatus,
Expand Down Expand Up @@ -47,28 +45,6 @@ export default function CombinedAlertBadge({rule}: Props) {
);
}

const isIssueAlertInstance = isIssueAlert(rule);
if (!isIssueAlertInstance && rule.monitorType === MonitorType.ACTIVATED) {
const isWaiting =
!rule.activations?.length ||
(rule.activations?.length && rule.activations[0]!.isComplete);

return (
<Tooltip
title={tct('Metric Alert Status: [status]', {
status: isWaiting ? 'Ready to monitor' : 'Monitoring',
})}
>
<AlertBadge
status={rule?.latestIncident?.status}
activationStatus={
isWaiting ? ActivationStatus.WAITING : ActivationStatus.MONITORING
}
/>
</Tooltip>
);
}

return (
<Tooltip
title={
Expand Down
15 changes: 2 additions & 13 deletions static/app/views/alerts/list/rules/row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,9 @@ import {Tooltip} from 'sentry/components/tooltip';
import {IconChevron, IconEllipsis, IconUser} from 'sentry/icons';
import {t, tct} from 'sentry/locale';
import {space} from 'sentry/styles/space';
import {MonitorType} from 'sentry/types/alerts';
import type {Actor} from 'sentry/types/core';
import type {Project} from 'sentry/types/project';
import {useUserTeams} from 'sentry/utils/useUserTeams';
import ActivatedMetricAlertRuleStatus from 'sentry/views/alerts/list/rules/activatedMetricAlertRuleStatus';
import AlertLastIncidentActivationInfo from 'sentry/views/alerts/list/rules/alertLastIncidentActivationInfo';
import AlertRuleStatus from 'sentry/views/alerts/list/rules/alertRuleStatus';
import CombinedAlertBadge from 'sentry/views/alerts/list/rules/combinedAlertBadge';
import {getActor} from 'sentry/views/alerts/list/rules/utils';
Expand Down Expand Up @@ -60,11 +57,7 @@ function RuleListRow({
}: Props) {
const {teams: userTeams} = useUserTeams();
const [assignee, setAssignee] = useState<string>('');

const isActivatedAlertRule =
rule.type === CombinedAlertType.METRIC && rule.monitorType === MonitorType.ACTIVATED;
const isUptime = rule.type === CombinedAlertType.UPTIME;

const slug = isUptime ? rule.projectSlug : rule.projects[0]!;

const editKey = {
Expand Down Expand Up @@ -235,19 +228,15 @@ function RuleListRow({
{rule.name} {titleBadge}
</Link>
</AlertName>
<AlertIncidentDate>
<AlertLastIncidentActivationInfo rule={rule} />
</AlertIncidentDate>
<AlertIncidentDate />
</AlertNameAndStatus>
</AlertNameWrapper>
<FlexCenter>
<FlexCenter>
<CombinedAlertBadge rule={rule} />
</FlexCenter>
<MarginLeft>
{isActivatedAlertRule ? (
<ActivatedMetricAlertRuleStatus rule={rule} />
) : isUptime ? (
{isUptime ? (
rule.status === UptimeMonitorStatus.FAILED ? (
t('Down')
) : (
Expand Down
5 changes: 0 additions & 5 deletions static/app/views/alerts/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,6 @@ export enum IncidentStatus {
CRITICAL = 20,
}

export enum ActivationStatus {
WAITING = 0,
MONITORING = 1,
}

export enum IncidentStatusMethod {
MANUAL = 1,
RULE_UPDATED = 2,
Expand Down
1 change: 0 additions & 1 deletion tests/js/fixtures/metricRule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ export function MetricRuleFixture(
params: Partial<SavedMetricRule> = {}
): SavedMetricRule {
return {
activations: [],
status: 0,
dateCreated: '2019-07-31T23:02:02.731Z',
dataset: Dataset.ERRORS,
Expand Down
18 changes: 0 additions & 18 deletions tests/js/fixtures/metricRuleActivation.ts

This file was deleted.

Loading