Explorar el Código

AMBARI-10085. Alerts Badge is shown red but only Warning-alerts present (onechiporenko)

Oleg Nechiporenko hace 10 años
padre
commit
656fd855fa

+ 1 - 1
ambari-web/app/controllers/main/alert_definitions_controller.js

@@ -123,6 +123,6 @@ App.MainAlertDefinitionsController = Em.ArrayController.extend({
    * @type {Boolean}
    */
   isCriticalAlerts: function () {
-    return !this.get('content').everyProperty('summary.CRITICAL.count', 0);
+    return this.get('content').invoke('getWithDefault', 'summary.CRITICAL.count', 0).reduce(Em.sum, 0) !== 0;
   }.property('content.@each.summary')
 });

+ 20 - 0
ambari-web/test/controllers/main/alert_definitions_controller_test.js

@@ -53,4 +53,24 @@ describe('App.MainAlertDefinitionsController', function() {
 
   });
 
+  describe('#isCriticalAlerts', function () {
+
+    beforeEach(function () {
+      controller.set('content', Em.A([
+        Em.Object.create({summary: {CRITICAL: {count: 0}}}),
+        Em.Object.create({summary: {CRITICAL: {}}})
+      ]));
+    });
+
+    it('if summary is undefined, 0 should be used', function () {
+      expect(controller.get('isCriticalAlerts')).to.be.false;
+    });
+
+    it('should be true, if some CRITICAL count is greater than 0', function () {
+      controller.get('content').pushObject(Em.Object.create({summary: {CRITICAL: {count: 1}}}));
+      expect(controller.get('isCriticalAlerts')).to.be.true;
+    });
+
+  });
+
 });