Jelajahi Sumber

AMBARI-10329. An error badge showing "0" appears after hitting Next on Select Stack page (alexantonenko)

Alex Antonenko 10 tahun lalu
induk
melakukan
22fb15a0af

+ 1 - 2
ambari-web/app/templates/wizard/step1.hbs

@@ -34,11 +34,10 @@
         <i {{bindAttr class=":pull-left :accordion-toggle view.isRLCollapsed:icon-caret-right:icon-caret-down"}}></i>
         <a class="accordion-toggle">
           {{t installer.step1.advancedRepo.title}}
-          {{#if view.isSubmitDisabled}}
+          {{#if view.showErrorsWarningCount}}
             <span class="badge badge-important">{{view.totalErrorCnt}}</span>
           {{/if}}
         </a>
-
       </div>
       <div class="accordion-body collapse in">
         <div class="accordion-inner">

+ 8 - 0
ambari-web/app/views/wizard/step1_view.js

@@ -87,6 +87,14 @@ App.WizardStep1View = Em.View.extend({
     return this.get('invalidFormatUrlExist') || this.get('isNoOsChecked') || this.get('invalidUrlExist') || this.get('controller.content.isCheckInProgress');
   }.property('invalidFormatUrlExist', 'isNoOsChecked', 'invalidUrlExist', 'controller.content.isCheckInProgress'),
 
+  /**
+   * Enable error count badge
+   * @type {bool}
+   */
+  showErrorsWarningCount: function () {
+    return this.get('isSubmitDisabled') && !!this.get('totalErrorCnt');
+  }.property('isSubmitDisabled', 'totalErrorCnt'),
+
   /**
    * Verify if some invalid repo-urls exist
    * @type {bool}

+ 30 - 0
ambari-web/test/views/wizard/step1_view_test.js

@@ -360,6 +360,36 @@ describe('App.WizardStep1View', function () {
     });
   });
 
+  describe('#showErrorsWarningCount', function() {
+    var tests = [
+      {
+        isSubmitDisabled: true,
+        totalErrorCnt: 0,
+        e: false
+      },
+      {
+        isSubmitDisabled: true,
+        totalErrorCnt: 1,
+        e: true
+      },
+      {
+        isSubmitDisabled: false,
+        totalErrorCnt: 0,
+        e: false
+      }
+    ];
+    tests.forEach(function(test) {
+      it(test.isSubmitDisabled.toString() + ' ' + test.totalErrorCnt.toString(), function () {
+        var view = App.WizardStep1View.create();
+        view.reopen({
+          isSubmitDisabled: test.isSubmitDisabled,
+          totalErrorCnt: test.totalErrorCnt
+        });
+        expect(view.get('showErrorsWarningCount')).to.equal(test.e);
+      })
+    });
+  });
+
   describe('#invalidUrlExist', function () {
     var tests = Em.A([
       {