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 Thu, 31 Aug 2017 15:05:45 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 638fc708c -> 3fd40043f


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/3fd40043
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3fd40043
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3fd40043

Branch: refs/heads/trunk
Commit: 3fd40043f1b68e9b29d046cfc8b3285d4ef7ee35
Parents: 638fc70
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Thu Aug 31 16:39:17 2017 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Thu Aug 31 18:05:20 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/3fd40043/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 f11cdd0..6e7af4a 100644
--- a/ambari-web/app/mixins/common/configs/configs_saver.js
+++ b/ambari-web/app/mixins/common/configs/configs_saver.js
@@ -135,7 +135,7 @@ App.ConfigsSaverMixin = Em.Mixin.create({
       if (configGroup && !configGroup.get('isDefault')) {
         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);
         }
@@ -147,10 +147,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'));
+      });
   },
 
   saveConfigsForDefaultGroup: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/3fd40043/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 e8e03ea..9099e54 100644
--- a/ambari-web/test/mixins/common/configs/configs_saver_test.js
+++ b/ambari-web/test/mixins/common/configs/configs_saver_test.js
@@ -1196,18 +1196,63 @@ describe('App.ConfigsSaverMixin', function() {
     it('no configs modified', function() {
       expect(mixin.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(mixin.isOverriddenConfigsModified([
         Em.Object.create({
+          name: '2',
           savedValue: '1',
-          value: '2'
+          value: '2',
+          isFinal: false,
+          savedIsFinal: false
+        })
+      ], Em.Object.create({
+        properties: [
+          {name: '2'}
+        ]
+      }))).to.be.true;
+    });
+    it('config isFinal modified', function() {
+      expect(mixin.isOverriddenConfigsModified([
+        Em.Object.create({
+          name: '2',
+          savedValue: '2',
+          value: '2',
+          isFinal: true,
+          savedIsFinal: false
         })
-      ])).to.be.true;
+      ], Em.Object.create({
+        properties: [
+          {name: '2'}
+        ]
+      }))).to.be.true;
+    });
+    it('one config removed', function() {
+      expect(mixin.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