Repository: ambari
Updated Branches:
  refs/heads/trunk 4189dcca8 -> 742f3f863


AMBARI-10850. Save button doesn't disable when invalid configs present on 
enhanced config tab. (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 742f3f86392f02468066abf0535a371e05956220
Parents: 4189dcc
Author: Alex Antonenko <hiv...@gmail.com>
Authored: Wed Apr 29 22:48:01 2015 +0300
Committer: Alex Antonenko <hiv...@gmail.com>
Committed: Thu Apr 30 00:05:54 2015 +0300

----------------------------------------------------------------------
 .../models/configs/objects/service_config.js    |  8 +++--
 .../wizard/slave_component_groups_controller.js |  5 ++-
 .../configs/objects/service_config_test.js      | 34 ++++++++++++++++++++
 3 files changed, 44 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/742f3f86/ambari-web/app/models/configs/objects/service_config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/configs/objects/service_config.js 
b/ambari-web/app/models/configs/objects/service_config.js
index b83b781..fe4c8f0 100644
--- a/ambari-web/app/models/configs/objects/service_config.js
+++ b/ambari-web/app/models/configs/objects/service_config.js
@@ -32,7 +32,8 @@ App.ServiceConfig = Ember.Object.extend({
       masterErrors = 0,
       slaveErrors = 0,
       configs = this.get('configs'),
-      configCategories = this.get('configCategories');
+      configCategories = this.get('configCategories'),
+      enhancedConfigsErrors = 0;
     configCategories.forEach(function (_category) {
       slaveErrors += _category.get('slaveErrorCount');
       _category.set('nonSlaveErrorCount', 0);
@@ -43,6 +44,9 @@ App.ServiceConfig = Ember.Object.extend({
         category.incrementProperty('nonSlaveErrorCount');
         masterErrors++;
       }
+      if (!item.get('isValid') && item.get('widget') && item.get('isVisible')) 
{
+        enhancedConfigsErrors++;
+      }
       if (item.get('overrides')) {
         item.get('overrides').forEach(function (e) {
           if (e.error) {
@@ -54,7 +58,7 @@ App.ServiceConfig = Ember.Object.extend({
         });
       }
     });
-    return masterErrors + slaveErrors + overrideErrors;
+    return masterErrors + slaveErrors + overrideErrors + enhancedConfigsErrors;
   }.property('configs.@each.isValid', 'configs.@each.isVisible', 
'configCategories.@each.slaveErrorCount', 'configs.@each.overrideErrorTrigger'),
 
   isPropertiesChanged: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/742f3f86/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/wizard/slave_component_groups_controller.js 
b/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
index d26812a..e692a4f 100644
--- a/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
+++ b/ambari-web/test/controllers/wizard/slave_component_groups_controller.js
@@ -21,6 +21,7 @@ var App = require('app');
 require('utils/helper');
 require('controllers/wizard/slave_component_groups_controller');
 
+var configPropertyHelper = require('utils/configs/config_property_helper');
 var controller;
 describe('App.SlaveComponentGroupsController', function () {
 
@@ -225,12 +226,14 @@ describe('App.SlaveComponentGroupsController', function 
() {
             initialValue: Em.K,
             validate: Em.K
           });
-        }   
+        }
       });
+      sinon.stub(configPropertyHelper, 'initialValue', Em.K);
     });
     afterEach(function () {
       App.ServiceConfigProperty.create.restore();
       App.config.get.restore();
+      configPropertyHelper.initialValue.restore();
     });
     it('should return created config', function () {
       var res = 
JSON.parse(JSON.stringify(controller.componentProperties('HBASE')));

http://git-wip-us.apache.org/repos/asf/ambari/blob/742f3f86/ambari-web/test/models/configs/objects/service_config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/configs/objects/service_config_test.js 
b/ambari-web/test/models/configs/objects/service_config_test.js
index cfa015c..ff848b2 100644
--- a/ambari-web/test/models/configs/objects/service_config_test.js
+++ b/ambari-web/test/models/configs/objects/service_config_test.js
@@ -141,6 +141,40 @@ describe('App.ServiceConfig', function () {
       expect(serviceConfig.get('configCategories').findProperty('name', 
'c0').get('nonSlaveErrorCount')).to.equal(2);
       expect(serviceConfig.get('configCategories').findProperty('name', 
'c1').get('nonSlaveErrorCount')).to.equal(1);
     });
+    it('should include invalid properties with widgets', function() {
+      serviceConfig.setProperties({
+        configs: [
+          Em.Object.create({
+            isValid: false,
+            widget: Em.View,
+            isVisible: true,
+            category: 'some1'
+          }),
+          Em.Object.create({
+            isValid: false,
+            widget: Em.View,
+            isVisible: true,
+            category: 'some2'
+          }),
+          Em.Object.create({
+            isValid: false,
+            widget: null,
+            isVisible: true,
+            category: 'some2'
+          }),
+          Em.Object.create({
+            isValid: false,
+            widget: Em.View,
+            isVisible: true
+          })
+        ],
+        configCategories: [
+          Em.Object.create({ name: 'some1', slaveErrorCount: 0}),
+          Em.Object.create({ name: 'some2', slaveErrorCount: 0})
+        ]
+      });
+      expect(serviceConfig.get('errorCount')).to.equal(4);
+    });
   });
 
 });

Reply via email to