Przeglądaj źródła

AMBARI-8511. Alerts UI: Disabling alert-definition not updating alert-instance counts (onechiporenko)

Oleg Nechiporenko 10 lat temu
rodzic
commit
c6f574349f

+ 8 - 0
ambari-web/app/mappers/alert_definition_summary_mapper.js

@@ -41,5 +41,13 @@ App.alertDefinitionSummaryMapper = App.QuickDataMapper.create({
         });
       }
     });
+
+    // clear summary for disabled alert definitions
+    alertDefinitions.forEach(function (definition) {
+      if (!definition.get('enabled')) {
+        definition.set('summary', {});
+      }
+    });
+
   }
 });

+ 13 - 5
ambari-web/test/mappers/alert_definition_summary_mapper_test.js

@@ -24,11 +24,12 @@ describe('App.alertDefinitionSummaryMapper', function () {
   describe('#map', function() {
 
     var testModels = [
-        App.PortAlertDefinition.createRecord({id: 1, type: 'PORT'}),
-        App.MetricsAlertDefinition.createRecord({id: 2, type: 'METRICS'}),
-        App.WebAlertDefinition.createRecord({id: 3, type: 'WEB'}),
-        App.AggregateAlertDefinition.createRecord({id: 4, type: 'AGGREGATE'}),
-        App.ScriptAlertDefinition.createRecord({id: 5, type: 'SCRIPT'})
+        App.PortAlertDefinition.createRecord({id: 1, enabled: true, type: 'PORT'}),
+        App.MetricsAlertDefinition.createRecord({id: 2, enabled: true, type: 'METRICS'}),
+        App.WebAlertDefinition.createRecord({id: 3, enabled: true, type: 'WEB'}),
+        App.AggregateAlertDefinition.createRecord({id: 4, enabled: true, type: 'AGGREGATE'}),
+        App.ScriptAlertDefinition.createRecord({id: 5, enabled: true, type: 'SCRIPT'}),
+        App.ScriptAlertDefinition.createRecord({id: 6, enabled: false, type: 'SCRIPT', summary: {OK: 1}})
       ],
       dataToMap = {
         alerts_summary_grouped: [
@@ -120,6 +121,13 @@ describe('App.alertDefinitionSummaryMapper', function () {
 
     });
 
+    it('should clear summary for disabled definitions', function () {
+
+      App.alertDefinitionSummaryMapper.map(dataToMap);
+      expect(App.ScriptAlertDefinition.find().findProperty('id', 6).get('summary')).to.eql({});
+
+    });
+
   });
 
 });