From bd2427fdbe7f90a336fa97a61a820385fd9fc740 Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Tue, 28 Feb 2023 11:02:31 -0800 Subject: [PATCH 1/3] fix(alerts): Remove null projects from alerts list --- static/app/views/alerts/list/rules/index.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/static/app/views/alerts/list/rules/index.tsx b/static/app/views/alerts/list/rules/index.tsx index be6e6ad3862744..477394706b1fb5 100644 --- a/static/app/views/alerts/list/rules/index.tsx +++ b/static/app/views/alerts/list/rules/index.tsx @@ -13,6 +13,7 @@ import SentryDocumentTitle from 'sentry/components/sentryDocumentTitle'; import {IconArrow} from 'sentry/icons'; import {t} from 'sentry/locale'; import {Organization, PageFilters, Project} from 'sentry/types'; +import {defined} from 'sentry/utils'; import trackAdvancedAnalyticsEvent from 'sentry/utils/analytics/trackAdvancedAnalyticsEvent'; import Projects from 'sentry/utils/projects'; import Teams from 'sentry/utils/teams'; @@ -59,7 +60,7 @@ class AlertRulesList extends AsyncComponent projects).flat())]; } From 5ff8107ba5391977bf68cd1dd1d325ccd20c370b Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Tue, 28 Feb 2023 11:21:23 -0800 Subject: [PATCH 2/3] handle null alert rule in all areas --- static/app/views/alerts/list/rules/index.tsx | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/static/app/views/alerts/list/rules/index.tsx b/static/app/views/alerts/list/rules/index.tsx index 477394706b1fb5..7ef1b9c9ca9ada 100644 --- a/static/app/views/alerts/list/rules/index.tsx +++ b/static/app/views/alerts/list/rules/index.tsx @@ -32,7 +32,7 @@ type Props = RouteComponentProps<{}, {}> & { }; type State = { - ruleList?: CombinedMetricIssueAlerts[] | null; + ruleList?: Array | null; teamFilterSearch?: string; }; @@ -59,12 +59,6 @@ class AlertRulesList extends AsyncComponent projects).flat())]; - } - handleChangeFilter = (activeFilters: string[]) => { const {router, location} = this.props; const {cursor: _cursor, page: _page, ...currentQuery} = location.query; @@ -134,9 +128,13 @@ class AlertRulesList extends AsyncComponent projects).flat()), + ]; const sort: { asc: boolean; @@ -210,12 +208,12 @@ class AlertRulesList extends AsyncComponent - + {({initiallyLoaded, projects}) => - ruleList?.map(rule => ( + ruleList.map(rule => ( Date: Tue, 28 Feb 2023 11:23:25 -0800 Subject: [PATCH 3/3] just use uniq --- static/app/views/alerts/list/rules/index.tsx | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/static/app/views/alerts/list/rules/index.tsx b/static/app/views/alerts/list/rules/index.tsx index 7ef1b9c9ca9ada..86a68e781a553a 100644 --- a/static/app/views/alerts/list/rules/index.tsx +++ b/static/app/views/alerts/list/rules/index.tsx @@ -1,6 +1,7 @@ import {Component} from 'react'; import {RouteComponentProps} from 'react-router'; import styled from '@emotion/styled'; +import uniq from 'lodash/uniq'; import {addErrorMessage, addMessage} from 'sentry/actionCreators/indicator'; import AsyncComponent from 'sentry/components/asyncComponent'; @@ -132,9 +133,7 @@ class AlertRulesList extends AsyncComponent projects).flat()), - ]; + const projectsFromResults = uniq(ruleList.flatMap(({projects}) => projects)); const sort: { asc: boolean;