ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject ambari git commit: AMBARI-21862. Unable to remove override from config group (akovalenko)
Date Tue, 26 Sep 2017 15:48:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 4f1dbbba7 -> 4fc5312c8


AMBARI-21862. Unable to remove override from config group (akovalenko)


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

Branch: refs/heads/branch-2.5
Commit: 4fc5312c82288a4047abcd47bdb0c10bce83c1ef
Parents: 4f1dbbb
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Thu Aug 31 16:42:55 2017 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Tue Sep 26 18:14:18 2017 +0300

----------------------------------------------------------------------
 .../app/mixins/common/configs/configs_saver.js  | 12 +++--
 .../mixins/common/configs/configs_saver_test.js | 55 ++++++++++++++++++--
 2 files changed, 58 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4fc5312c/ambari-web/app/mixins/common/configs/configs_saver.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js
index 12b6e15..64a4099 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -149,7 +149,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
 
           var overriddenConfigs = this.getConfigsForGroup(configs, configGroup.get('name'));
 
-          if (Em.isArray(overriddenConfigs) && this.isOverriddenConfigsModified(overriddenConfigs))
{
+          if (Em.isArray(overriddenConfigs) && this.isOverriddenConfigsModified(overriddenConfigs,
configGroup)) {
             var successCallback = this.get('content.serviceName') === serviceName ? 'putConfigGroupChangesSuccess'
: null;
             this.saveGroup(overriddenConfigs, configGroup, this.get('serviceConfigVersionNote'),
successCallback);
           }
@@ -162,10 +162,14 @@ App.ConfigsSaverMixin = Em.Mixin.create({
    * @param {Array} overriddenConfigs
    * @returns {boolean}
    */
-  isOverriddenConfigsModified: function(overriddenConfigs) {
-    return overriddenConfigs.some(function(config) {
-      return config.get('savedValue') !== config.get('value');
+  isOverriddenConfigsModified: function(overriddenConfigs, group) {
+    var hasChangedConfigs = overriddenConfigs.some(function(config) {
+      return config.get('savedValue') !== config.get('value') || config.get('savedIsFinal')
!== config.get('isFinal');
     });
+    var overriddenConfigsNames = overriddenConfigs.mapProperty('name');
+    return hasChangedConfigs || group.get('properties').some(function (property) {
+        return !overriddenConfigsNames.contains(Em.get(property, 'name'));
+      });
   },
 
   /*********************************** 0. HELPERS ********************************************/

http://git-wip-us.apache.org/repos/asf/ambari/blob/4fc5312c/ambari-web/test/mixins/common/configs/configs_saver_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mixins/common/configs/configs_saver_test.js b/ambari-web/test/mixins/common/configs/configs_saver_test.js
index b0258a3..d57617a 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -289,18 +289,63 @@ describe('App.ConfigsSaverMixin', function() {
     it('no configs modified', function() {
       expect(instanceObject.isOverriddenConfigsModified([
         Em.Object.create({
+          name: '1',
           savedValue: '1',
-          value: '1'
+          value: '1',
+          isFinal: false,
+          savedIsFinal: false
         })
-      ])).to.be.false;
+      ], Em.Object.create({
+        properties: [
+          {name: '1'}
+        ]
+      }))).to.be.false;
     });
-    it('one config modified', function() {
+    it('config value modified', function() {
       expect(instanceObject.isOverriddenConfigsModified([
         Em.Object.create({
+          name: '2',
           savedValue: '1',
-          value: '2'
+          value: '2',
+          isFinal: false,
+          savedIsFinal: false
         })
-      ])).to.be.true;
+      ], Em.Object.create({
+        properties: [
+          {name: '2'}
+        ]
+      }))).to.be.true;
+    });
+    it('config isFinal modified', function() {
+      expect(instanceObject.isOverriddenConfigsModified([
+        Em.Object.create({
+          name: '2',
+          savedValue: '2',
+          value: '2',
+          isFinal: true,
+          savedIsFinal: false
+        })
+      ], Em.Object.create({
+        properties: [
+          {name: '2'}
+        ]
+      }))).to.be.true;
+    });
+    it('one config removed', function() {
+      expect(instanceObject.isOverriddenConfigsModified([
+        Em.Object.create({
+          name: '3',
+          savedValue: '3',
+          value: '3',
+          isFinal: false,
+          savedIsFinal: false
+        })
+      ], Em.Object.create({
+        properties: [
+          {name: '2'},
+          {name: '3'}
+        ]
+      }))).to.be.true;
     });
   });
 });


Mime
View raw message