Преглед изворни кода

AMBARI-8915. Alerts UI: Maint Mode status display and general cleanup #6. Additional patch. (akovalenko)

Aleksandr Kovalenko пре 10 година
родитељ
комит
9d31c3ce54

+ 1 - 1
ambari-web/app/templates/main/service/info/summary.hbs

@@ -49,7 +49,7 @@
     <div class="box">
       <div class="box-header summary-box-header">
         <h4>{{controller.content.label}} {{t services.service.info.menu.summary}}</h4>
-        {{#if view.alertsCount}}
+        {{#if view.hasAlertDefinitions}}
           <span {{action "showServiceAlertsPopup" controller.content target="controller"}}{{bindAttr class=":pull-right view.alertsCount:alerts-count-label:no-alerts-label :label"}}>{{view.alertsCountLabel}}</span>
         {{/if}}
       </div>

+ 8 - 0
ambari-web/app/views/main/service/info/summary.js

@@ -252,6 +252,14 @@ App.MainServiceInfoSummaryView = Em.View.extend(App.UserPref, {
     return !!this.get('controller.content.criticalAlertsCount');
   }.property('controller.content.criticalAlertsCount'),
 
+  /**
+   * Define if service has alert definitions defined
+   * @type {Boolean}
+   */
+  hasAlertDefinitions: function () {
+    return App.AlertDefinition.getAllDefinitions().someProperty('serviceName', this.get('controller.content.serviceName'));
+  }.property('controller.content.serviceName'),
+
   restartRequiredHostsAndComponents:function () {
     return this.get('controller.content.restartRequiredHostsAndComponents');
   }.property('controller.content.restartRequiredHostsAndComponents'),

+ 33 - 0
ambari-web/test/views/main/service/info/summary_test.js

@@ -104,4 +104,37 @@ describe('App.MainServiceInfoSummaryView', function() {
 
   });
 
+  describe('#hasAlertDefinitions', function () {
+
+    beforeEach(function () {
+      sinon.stub(App.AlertDefinition, 'getAllDefinitions', function () {
+        return [
+          {
+            serviceName: 'HDFS'
+          },
+          {
+            serviceName: 'YARN'
+          }
+        ];
+      });
+    });
+
+    afterEach(function () {
+      App.AlertDefinition.getAllDefinitions.restore();
+    });
+
+    it('should return true if at least one alert definition for this service exists', function () {
+      view.set('controller.content', Em.Object.create({
+        serviceName: 'HDFS'
+      }));
+      expect(view.get('hasAlertDefinitions')).to.be.true;
+
+      it('should return false if there is no alert definition for this service', function () {
+        view.set('controller.content', Em.Object.create({
+          serviceName: 'ZOOKEEPER'
+        }));
+        expect(view.get('hasAlertDefinitions')).to.be.false;
+      });
+    })
+  });
 });