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/04/09 00:52:48 UTC

ambari git commit: AMBARI-10375. Editing configs in config-group running into weird situations (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk 728b2d470 -> a1f409cb2


AMBARI-10375. Editing configs in config-group running into weird situations (alexantonenko)


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

Branch: refs/heads/trunk
Commit: a1f409cb206442c55fd043610a415624eda02b7d
Parents: 728b2d4
Author: Alex Antonenko <hi...@gmail.com>
Authored: Thu Apr 9 01:52:31 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Thu Apr 9 01:52:43 2015 +0300

----------------------------------------------------------------------
 .../mixins/common/configs/enhanced_configs.js   | 34 ++++++++++++--------
 ambari-web/app/utils/config.js                  |  1 +
 .../configs/widgets/config_widget_view.js       |  1 +
 .../widgets/slider_config_widget_view.js        |  1 +
 ambari-web/app/views/common/controls_view.js    | 18 ++++++++---
 .../common/configs/enhanced_configs_test.js     | 25 +++++++++++++-
 .../widgets/list_config_widget_view_test.js     | 11 ++++++-
 7 files changed, 71 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/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 467f31c..c14867b 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -154,6 +154,22 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
 
 
   /**
+   * disable saving recommended value for current config
+   * @param config
+   * @method removeCurrentFromDependentList
+   */
+  removeCurrentFromDependentList: function (config) {
+    var current = this.get('_dependentConfigValues').filterProperty('propertyName', config.get('name')).findProperty('fileName', App.config.getConfigTagFromFileName(config.get('filename')));
+    if (current) {
+      Em.setProperties(current, {
+          'saveRecommended': false,
+          'saveRecommendedDefault': false,
+          'value': config.get('value')
+        });
+    }
+  },
+
+  /**
    * sends request to get values for dependent configs
    * @param changedConfigs
    * @param initial
@@ -162,7 +178,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    */
   getRecommendationsForDependencies: function(changedConfigs, initial, onComplete) {
     if (Em.isArray(changedConfigs) && changedConfigs.length > 0 || initial) {
-      var self = this;
       var recommendations = this.get('hostGroups');
       var configs = this._getConfigsByGroup(this.get('stepConfigs'));
       recommendations.blueprint.configurations = blueprintUtils.buildConfigsJSON(this.get('services'), configs);
@@ -188,7 +203,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         success: 'dependenciesSuccess',
         error: 'dependenciesError',
         callback: function() {
-          self.onRecommendationsReceived();
           if (onComplete) {
             onComplete()
           }
@@ -200,14 +214,6 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
   },
 
   /**
-   * complete callback on <code>getRecommendationsForDependencies<code>
-   * @method onRecommendationsReceived
-   */
-  onRecommendationsReceived: function() {
-    this.set('recommendationTimeStamp', (new Date).getTime());
-  },
-
-  /**
    * shows popup with results for recommended value
    * if case properties that was changes belongs to not default group
    * user should pick to what config group from dependent service dependent properties will be saved
@@ -233,7 +239,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    * method to show popup with dependent configs
    * @method showChangedDependentConfigs
    */
-  showChangedDependentConfigs: function(event, callback) {
+  showChangedDependentConfigs: function(event, callback, secondary) {
     var self = this;
     if (self.get('_dependentConfigValues.length') > 0) {
       App.showDependentConfigsPopup(this.get('_dependentConfigValues'), function() {
@@ -241,7 +247,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         if (callback) {
           callback();
         }
-      });
+      }, secondary);
     } else {
       if (callback) {
         callback();
@@ -257,6 +263,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    * @param opt
    */
   dependenciesError: function(jqXHR, ajaxOptions, error, opt) {
+    this.set('recommendationTimeStamp', (new Date).getTime());
     App.ajax.defaultErrorHandler(jqXHR, opt.url, opt.method, jqXHR.status);
   },
 
@@ -322,6 +329,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
         }
       })
     });
+    this.set('recommendationTimeStamp', (new Date).getTime());
   },
 
   /**
@@ -450,4 +458,4 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
       }
     }
   }
-});
\ No newline at end of file
+});

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 162ea1e..1b7ae4a 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -311,6 +311,7 @@ App.config = Em.Object.create({
           defaultValue: properties[index],
           filename: filename,
           isUserProperty: !advancedConfig,
+          isVisible: !!service,
           isOverridable: true,
           isReconfigurable: true,
           isRequired: isAdvanced,

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/ambari-web/app/views/common/configs/widgets/config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/config_widget_view.js b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
index d24e845..d75dd03 100644
--- a/ambari-web/app/views/common/configs/widgets/config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/config_widget_view.js
@@ -82,6 +82,7 @@ App.ConfigWidgetView = Em.View.extend(App.SupportsDependentConfigs, App.WidgetPo
    */
   restoreValue: function () {
     this.set('config.value', this.get('config.defaultValue'));
+    this.get('controller').removeCurrentFromDependentList(this.get('config'));
     this.sendRequestRorDependentConfigs(this.get('config'));
 
     if (this.get('config.supportsFinal')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
index 7dc0c13..29c0ac7 100644
--- a/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
+++ b/ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js
@@ -255,6 +255,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
          * action to run sendRequestRorDependentConfigs when
          * we have changed config value within slider
          */
+        self.get('controller').removeCurrentFromDependentList(self.get('config'));
         self.sendRequestRorDependentConfigs(self.get('config'));
       });
     this.set('slider', slider);

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/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 1b9e54b..364cd92 100644
--- a/ambari-web/app/views/common/controls_view.js
+++ b/ambari-web/app/views/common/controls_view.js
@@ -63,6 +63,14 @@ App.ServiceConfigPopoverSupport = Ember.Mixin.create({
 App.SupportsDependentConfigs = Ember.Mixin.create({
 
   /**
+   * do not apply recommended value if user change value by himself.
+   */
+  keyUp: function() {
+    if (App.get('supports.enhancedConfigs')) {
+      this.get('controller').removeCurrentFromDependentList(this.get('serviceConfig'));
+    }
+  },
+  /**
    * method send request to check if some of dependent configs was changes
    * and in case there was changes shows popup with info about changed configs
    */
@@ -202,7 +210,7 @@ App.ServiceConfigPasswordField = Ember.TextField.extend({
  * Textarea control
  * @type {*}
  */
-App.ServiceConfigTextArea = Ember.TextArea.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, {
+App.ServiceConfigTextArea = Ember.TextArea.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
 
   valueBinding: 'serviceConfig.value',
   rows: 4,
@@ -215,7 +223,7 @@ App.ServiceConfigTextArea = Ember.TextArea.extend(App.ServiceConfigPopoverSuppor
  * Textarea control for content type
  * @type {*}
  */
-App.ServiceConfigTextAreaContent = Ember.TextArea.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, {
+App.ServiceConfigTextAreaContent = Ember.TextArea.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
 
   valueBinding: 'serviceConfig.value',
   rows: 20,
@@ -234,7 +242,7 @@ App.ServiceConfigBigTextArea = App.ServiceConfigTextArea.extend(App.ServiceConfi
  * Checkbox control
  * @type {*}
  */
-App.ServiceConfigCheckbox = Ember.Checkbox.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, {
+App.ServiceConfigCheckbox = Ember.Checkbox.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
 
   allowedPairs: {
     'trueFalse': ["true", "false"],
@@ -336,7 +344,7 @@ App.ServiceConfigCheckboxWithDependencies = App.ServiceConfigCheckbox.extend({
   }
 });
 
-App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId, {
+App.ServiceConfigRadioButtons = Ember.View.extend(App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
   templateName: require('templates/wizard/controls_service_config_radio_buttons'),
 
   didInsertElement: function () {
@@ -688,7 +696,7 @@ App.ServiceConfigRadioButton = Ember.Checkbox.extend({
   }.property('parentView.serviceConfig.isEditable')
 });
 
-App.ServiceConfigComboBox = Ember.Select.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, {
+App.ServiceConfigComboBox = Ember.Select.extend(App.ServiceConfigPopoverSupport, App.ServiceConfigCalculateId, App.SupportsDependentConfigs, {
   contentBinding: 'serviceConfig.options',
   selectionBinding: 'serviceConfig.value',
   placeholderBinding: 'serviceConfig.defaultValue',

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/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 a9cbce7..bc88a9f 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -18,5 +18,28 @@
 
 var App = require('app');
 
-describe('App.EnhancedConfigsMixin', function() {});
+describe('App.EnhancedConfigsMixin', function() {
+
+  var mixinObject = Em.Controller.extend(App.EnhancedConfigsMixin, {});
+  var instanceObject = mixinObject.create({});
+  describe('#removeCurrentFromDependentList()', function() {
+    it('update some fields', function() {
+      instanceObject.get('_dependentConfigValues').pushObject({
+          saveRecommended: true,
+          saveRecommendedDefault: true,
+          propertyName: 'p1',
+          fileName: 'f1',
+          value: 'v1'
+        });
+      instanceObject.removeCurrentFromDependentList(Em.Object.create({name: 'p1', filename: 'f1.xml', value: 'v2'}));
+      expect(instanceObject.get('_dependentConfigValues')[0]).to.eql({
+        saveRecommended: false,
+        saveRecommendedDefault: false,
+        propertyName: 'p1',
+        fileName: 'f1',
+        value: 'v2'
+      });
+    });
+  });
+});
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/a1f409cb/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
index a64bf11..01e184a 100644
--- a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
+++ b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js
@@ -29,6 +29,7 @@ describe('App.ListConfigWidgetView', function () {
         name: 'a.b.c',
         defaultValue: '2,1',
         value: '2,1',
+        filename: 'f1',
         stackConfigProperty: Em.Object.create({
           valueAttributes: {
             entries: ['1', '2', '3', '4', '5'],
@@ -37,7 +38,8 @@ describe('App.ListConfigWidgetView', function () {
             selection_cardinality: '3'
           }
         })
-      })
+      }),
+      controller: App.MainServiceInfoConfigsController.create({})
     });
     view.willInsertElement();
     view.didInsertElement();
@@ -112,6 +114,12 @@ describe('App.ListConfigWidgetView', function () {
 
   describe('#restoreValue', function () {
 
+    beforeEach(function() {
+      sinon.stub(view.get('controller'), 'removeCurrentFromDependentList', Em.K)
+    });
+    afterEach(function() {
+      view.get('controller.removeCurrentFromDependentList').restore();
+    });
     it('should restore default value', function () {
       view.toggleOption({context: view.get('options')[0]});
       view.toggleOption({context: view.get('options')[1]});
@@ -119,6 +127,7 @@ describe('App.ListConfigWidgetView', function () {
       expect(view.get('config.value')).to.equal('3');
       view.restoreValue();
       expect(view.get('config.value')).to.equal('2,1');
+      expect(view.get('controller.removeCurrentFromDependentList')).to.be.called
     });
 
   });