AMBARI-21571 Making changes to a config group is forcing updates to other 
values which customer do not intend to change. (atkach)


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

Branch: refs/heads/branch-2.6
Commit: 7756f98d2f7997dc0ff968ffbe4032d7c2ee9e8a
Parents: 7fb0436
Author: Andrii Tkach <atk...@apache.org>
Authored: Tue Jul 25 16:15:47 2017 +0300
Committer: Andrii Tkach <atk...@apache.org>
Committed: Wed Jul 26 12:14:47 2017 +0300

----------------------------------------------------------------------
 .../mixins/common/configs/enhanced_configs.js   | 23 ++++++++--
 .../common/configs/enhanced_configs_test.js     | 44 ++++++++++++++++++++
 2 files changed, 64 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7756f98d/ambari-web/app/mixins/common/configs/enhanced_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js 
b/ambari-web/app/mixins/common/configs/enhanced_configs.js
index e86fb59..5668b8c 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -392,10 +392,10 @@ App.EnhancedConfigsMixin = 
Em.Mixin.create(App.ConfigWithOverrideRecommendationP
     var self = this;
     var recommendations = event ? this.get('changedProperties') : 
this.get('recommendations'),
       recommendedChanges = recommendations.filterProperty('isEditable'),
-      requiredChanges = recommendations.filterProperty('isEditable', false);
-    if (recommendations.length > 0) {
+      requiredChanges = this.filterRequiredChanges(recommendations);
+    if (recommendedChanges.length > 0 || requiredChanges.length > 0) {
       App.showDependentConfigsPopup(recommendedChanges, requiredChanges, 
function() {
-        self.onSaveRecommendedPopup(recommendations);
+        
self.onSaveRecommendedPopup(recommendedChanges.concat(requiredChanges));
         if (callback) callback();
       }, secondary);
     } else {
@@ -404,6 +404,23 @@ App.EnhancedConfigsMixin = 
Em.Mixin.create(App.ConfigWithOverrideRecommendationP
   },
 
   /**
+   *
+   * @param {Array} recommendations
+   * @returns {Array}
+   */
+  filterRequiredChanges: function(recommendations) {
+    return recommendations.filter(function(recommendation) {
+      if (recommendation.isEditable === false) {
+        if (!this.get('selectedConfigGroup.isDefault')) {
+          return App.ServiceConfigGroup.defaultGroupName !== 
recommendation.configGroup
+        } else {
+          return true;
+        }
+      }
+    }, this);
+  },
+
+  /**
    * update configs when toggle checkbox on dependent configs popup
    */
   onSaveRecommendedPopup: function(recommendations) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7756f98d/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js 
b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
index 880f4d2..3a41dc9 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -263,5 +263,49 @@ describe('App.EnhancedConfigsMixin', function() {
       )).to.be.true;
     });
   });
+
+  describe('#filterRequiredChanges', function() {
+
+    it('all recommendations editable', function() {
+      var recommendations = [
+        {
+          isEditable: true
+        }
+      ];
+      
expect(instanceObject.filterRequiredChanges(recommendations)).to.be.empty;
+    });
+
+    it('recommendations not editable when editing default config group', 
function() {
+      instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: 
true}));
+      var recommendations = [
+        {
+          isEditable: false
+        }
+      ];
+      
expect(instanceObject.filterRequiredChanges(recommendations)).to.be.eql(recommendations);
+    });
+
+    it('recommendations not editable when editing non-default config group for 
default group', function() {
+      instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: 
false}));
+      var recommendations = [
+        {
+          isEditable: false,
+          configGroup: App.ServiceConfigGroup.defaultGroupName
+        }
+      ];
+      
expect(instanceObject.filterRequiredChanges(recommendations)).to.be.empty;
+    });
+
+    it('recommendations not editable when editing non-default config group for 
non-default group', function() {
+      instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: 
false}));
+      var recommendations = [
+        {
+          isEditable: false,
+          configGroup: 'g1'
+        }
+      ];
+      
expect(instanceObject.filterRequiredChanges(recommendations)).to.be.eql(recommendations);
+    });
+  });
 });
 

Reply via email to