Browse Source

feat(alerts): Add lastTriggered date to Issue Alert rules on rules page (#33990)

* feat(alerts): Add warning/resolved status to Issue Alert rules

Add warning/resolved status to Issue Alerts on the Alert Rules page.

FIXES WOR-1696

* update 14 day check

* update test

* refactor to use moment

* remove unused styling for iconissues

* update test

* revert back to only show date triggered for issue alerts

* update tooltip copy
Kelly Carino 2 years ago
parent
commit
d22d02ee11

+ 1 - 1
static/app/views/alerts/rules/index.tsx

@@ -40,7 +40,7 @@ class AlertRulesList extends AsyncComponent<Props, State & AsyncComponent['state
     const {params, location} = this.props;
     const {query} = location;
 
-    query.expand = ['latestIncident'];
+    query.expand = ['latestIncident', 'lastTriggered'];
     query.team = getTeamParams(query.team);
 
     if (!query.sort) {

+ 10 - 5
static/app/views/alerts/rules/row.tsx

@@ -62,7 +62,15 @@ function RuleListRow({
 
   function renderLastIncidentDate(): React.ReactNode {
     if (isIssueAlert(rule)) {
-      return null;
+      if (!rule.lastTriggered) {
+        return '-';
+      }
+      return (
+        <div>
+          {t('Triggered ')}
+          <TimeSince date={rule.lastTriggered} />
+        </div>
+      );
     }
 
     if (!rule.latestIncident) {
@@ -219,13 +227,10 @@ function RuleListRow({
         </FlexCenter>
         <AlertNameAndStatus>
           <AlertName>{alertLink}</AlertName>
-          <AlertIncidentDate>
-            {!isIssueAlert(rule) && renderLastIncidentDate()}
-          </AlertIncidentDate>
+          <AlertIncidentDate>{renderLastIncidentDate()}</AlertIncidentDate>
         </AlertNameAndStatus>
       </AlertNameWrapper>
       <FlexCenter>{renderAlertRuleStatus()}</FlexCenter>
-
       <FlexCenter>
         <ProjectBadgeContainer>
           <ProjectBadge

+ 4 - 4
tests/js/spec/views/alerts/rules/index.spec.jsx

@@ -198,7 +198,7 @@ describe('AlertRulesList', () => {
       expect.objectContaining({
         query: {
           name: testQuery,
-          expand: ['latestIncident'],
+          expand: ['latestIncident', 'lastTriggered'],
           sort: ['incident_status', 'date_triggered'],
           team: ['myteams', 'unassigned'],
         },
@@ -224,7 +224,7 @@ describe('AlertRulesList', () => {
     expect(router.push).toHaveBeenCalledWith(
       expect.objectContaining({
         query: {
-          expand: ['latestIncident'],
+          expand: ['latestIncident', 'lastTriggered'],
           sort: ['incident_status', 'date_triggered'],
           team: '',
         },
@@ -253,7 +253,7 @@ describe('AlertRulesList', () => {
       '/organizations/org-slug/combined-rules/',
       expect.objectContaining({
         query: {
-          expand: ['latestIncident'],
+          expand: ['latestIncident', 'lastTriggered'],
           sort: ['incident_status', 'date_triggered'],
           team: ['myteams', 'unassigned'],
         },
@@ -273,7 +273,7 @@ describe('AlertRulesList', () => {
     expect(router.push).toHaveBeenCalledWith(
       expect.objectContaining({
         query: {
-          expand: ['latestIncident'],
+          expand: ['latestIncident', 'lastTriggered'],
           sort: ['incident_status', 'date_triggered'],
           team: '',
           cursor: '0:100:0',