Quellcode durchsuchen

AMBARI-11421. Ranger requirements popup is displayed twice (onechiporenko)

Oleg Nechiporenko vor 10 Jahren
Ursprung
Commit
fd66b4120c

+ 12 - 3
ambari-web/app/controllers/wizard/step4_controller.js

@@ -29,6 +29,8 @@ App.WizardStep4Controller = Em.ArrayController.extend({
    */
    */
   content: [],
   content: [],
 
 
+  isValidating: false,
+
   /**
   /**
    * Check / Uncheck 'Select All' checkbox with one argument; Check / Uncheck all other checkboxes with more arguments
    * Check / Uncheck 'Select All' checkbox with one argument; Check / Uncheck all other checkboxes with more arguments
    * @type {bool}
    * @type {bool}
@@ -64,7 +66,9 @@ App.WizardStep4Controller = Em.ArrayController.extend({
    * Drop errorStack content on selected state changes.
    * Drop errorStack content on selected state changes.
    **/
    **/
   clearErrors: function() {
   clearErrors: function() {
-    this.set('errorStack', []);
+    if (!this.get('isValidating')) {
+      this.set('errorStack', []);
+    }
   }.observes('@each.isSelected'),
   }.observes('@each.isSelected'),
 
 
   /**
   /**
@@ -155,6 +159,8 @@ App.WizardStep4Controller = Em.ArrayController.extend({
    * @method validate
    * @method validate
    **/
    **/
   validate: function() {
   validate: function() {
+    var result;
+    this.set('isValidating', true);
     this.serviceDependencyValidation();
     this.serviceDependencyValidation();
     this.fileSystemServiceValidation();
     this.fileSystemServiceValidation();
     if (this.get('wizardController.name') == 'installerController') {
     if (this.get('wizardController.name') == 'installerController') {
@@ -164,9 +170,12 @@ App.WizardStep4Controller = Em.ArrayController.extend({
     this.sparkValidation();
     this.sparkValidation();
     if (!!this.get('errorStack').filterProperty('isShown', false).length) {
     if (!!this.get('errorStack').filterProperty('isShown', false).length) {
       this.showError(this.get('errorStack').findProperty('isShown', false));
       this.showError(this.get('errorStack').findProperty('isShown', false));
-      return false;
+      result = false;
+    } else {
+      result = true;
     }
     }
-    return true;
+    this.set('isValidating', false);
+    return result;
   },
   },
 
 
   /**
   /**

+ 29 - 0
ambari-web/test/controllers/wizard/step4_test.js

@@ -778,4 +778,33 @@ describe('App.WizardStep4Controller', function () {
 
 
   });
   });
 
 
+  describe('#clearErrors', function () {
+
+    var cases = [
+      {
+        isValidating: true,
+        errorStack: [{}],
+        title: 'error stack shouldn\'t be cleared during validation'
+      },
+      {
+        isValidating: false,
+        errorStack: [],
+        title: 'error stack should be cleared'
+      }
+    ];
+
+    beforeEach(function () {
+      controller.set('errorStack', [{}]);
+    });
+
+    cases.forEach(function (item) {
+      it(item.title, function () {
+        controller.set('isValidating', item.isValidating);
+        controller.propertyDidChange('@each.isSelected');
+        expect(controller.get('errorStack')).to.eql(item.errorStack);
+      });
+    });
+
+  });
+
 });
 });