ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject ambari git commit: AMBARI-10085. Alerts Badge is shown red but only Warning-alerts present (onechiporenko)
Date Mon, 16 Mar 2015 17:18:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk fcb18659b -> 656fd855f


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/656fd855
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/656fd855
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/656fd855

Branch: refs/heads/trunk
Commit: 656fd855fa62c31bb23277fa1d0ad5ddbe8dc0f7
Parents: fcb1865
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Mon Mar 16 18:56:22 2015 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Mon Mar 16 19:18:37 2015 +0200

----------------------------------------------------------------------
 .../main/alert_definitions_controller.js        |  2 +-
 .../main/alert_definitions_controller_test.js   | 20 ++++++++++++++++++++
 2 files changed, 21 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/656fd855/ambari-web/app/controllers/main/alert_definitions_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alert_definitions_controller.js b/ambari-web/app/controllers/main/alert_definitions_controller.js
index 8f7fcb8..f1f7066 100644
--- a/ambari-web/app/controllers/main/alert_definitions_controller.js
+++ b/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')
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/656fd855/ambari-web/test/controllers/main/alert_definitions_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/alert_definitions_controller_test.js b/ambari-web/test/controllers/main/alert_definitions_controller_test.js
index 03a4d80..7d696f8 100644
--- a/ambari-web/test/controllers/main/alert_definitions_controller_test.js
+++ b/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;
+    });
+
+  });
+
 });


Mime
View raw message