You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/06/19 18:55:37 UTC

ambari git commit: AMBARI-12023. Enhanced configs: UNDO button not fully reset property for MapReduce2 (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk e7a4800b2 -> 2a8c9e9fa


AMBARI-12023. Enhanced configs: UNDO button not fully reset property for MapReduce2 (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 2a8c9e9fa30ac8708c118ac24ed7129804b8702a
Parents: e7a4800
Author: Alex Antonenko <hi...@gmail.com>
Authored: Fri Jun 19 19:51:56 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Fri Jun 19 19:51:56 2015 +0300

----------------------------------------------------------------------
 .../mixins/common/configs/enhanced_configs.js   | 21 ++++++++++++++++
 ambari-web/app/views/common/controls_view.js    |  5 ++++
 .../configs/widgets/config_widget_view_test.js  | 26 ++++++++++++++++++--
 3 files changed, 50 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/2a8c9e9f/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 5e57e7c..9b30a72 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -737,6 +737,27 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         }
       }
     }
+  },
+
+  /**
+   * Helper method to get property from the <code>stepConfigs</code>
+   *
+   * @param {String} name - config property name
+   * @param {} fileName - config property filename
+   * @return {App.ServiceConfigProperty|Boolean} - App.ServiceConfigProperty instance or <code>false</code> when property not found
+   */
+  findConfigProperty: function(name, fileName) {
+    if (!name && !fileName) return false;
+    if (this.get('stepConfigs') && this.get('stepConfigs.length')) {
+      return this.get('stepConfigs').mapProperty('configs').filter(function(item) {
+        return item.length;
+      }).reduce(function(p, c) {
+        if (p) {
+          return p.concat(c);
+        }
+      }).filterProperty('filename', fileName).findProperty('name', name);
+    }
+    return false;
   }
 
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/2a8c9e9f/ambari-web/app/views/common/controls_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/controls_view.js b/ambari-web/app/views/common/controls_view.js
index 4c03330..0ca78b0 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -126,6 +126,11 @@ App.SupportsDependentConfigs = Ember.Mixin.create({
           if (item.parentConfigs.length > 1) {
             item.parentConfigs.removeObject(parentConfig.get('name'));
           } else {
+            // reset property value
+            var property = controller.findConfigProperty(item.propertyName, App.config.getOriginalFileName(item.fileName));
+            if (property) {
+              property.set('value', property.get('savedValue') || property.get('initialValue'));
+            }
             return true;
           }
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/2a8c9e9f/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
index 30d7b71..91610e8 100644
--- a/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/config_widget_view_test.js
@@ -169,8 +169,9 @@ describe('App.ConfigWidgetView', function () {
   describe('#restoreDependentConfigs', function() {
     beforeEach(function() {
       view = App.ConfigWidgetView.create({
-        controller: Em.Object.create({
-          updateDependentConfigs: function() {}
+        controller: Em.Object.extend(App.EnhancedConfigsMixin, {
+        }).create({
+          updateDependentConfigs: function() {},
         }),
         config: Em.Object.create({ name: 'config1'})
       });
@@ -217,6 +218,27 @@ describe('App.ConfigWidgetView', function () {
       expect(view.get('controller._dependentConfigValues.length')).to.be.eql(2);
     });
 
+    it('dependent config value should be set with inital or saved when it has one parent', function() {
+      var ctrl = view.get('controller');
+      ctrl.set('stepConfigs', [
+        Em.Object.create({
+          configs: Em.A([
+            Em.Object.create({ name: 'dependent3', savedValue: '1', value: 2, filename: 'some-file.xml' }),
+            Em.Object.create({ name: 'dependent2', savedValue: '4', value: '10', filename: 'some-file.xml' })
+          ])
+        })
+      ]);
+      view.set('controller._dependentConfigValues', [
+        {propertyName: 'dependent1', parentConfigs: ['config1', 'config2'], fileName: 'some-file' },
+        {propertyName: 'dependent2', parentConfigs: ['config2', 'config1'], fileName: 'some-file'},
+        {propertyName: 'dependent3', parentConfigs: ['config1'], fileName: 'some-file' }
+      ]);
+      view.restoreDependentConfigs(view.get('config'));
+      expect(view.get('controller').findConfigProperty('dependent3', 'some-file.xml').get('value')).to.be.eql('1');
+      // config with multi dependency should not be updated
+      expect(view.get('controller').findConfigProperty('dependent2', 'some-file.xml').get('value')).to.be.eql('10');
+    });
+
   });
 
   describe('#isValueCompatibleWithWidget()', function() {