ソースを参照

AMBARI-10601 Going to HBase enhanced configs page causes config change (additional). (ababiichuk)

aBabiichuk 10 年 前
コミット
d539ffbb27

+ 1 - 0
ambari-web/app/mixins/unit_convert/convert_unit_widget_view_mixin.js

@@ -25,6 +25,7 @@ App.ConvertUnitWidgetViewMixin = Em.Mixin.create(App.BaseUnitConvertMixin, {
   /**
   /**
    * Get converted value according to widget value format from specified config property value.
    * Get converted value according to widget value format from specified config property value.
    *
    *
+   * @method widgetValueByConfigAttributes
    * @param {String|Number} value - config property value to convert
    * @param {String|Number} value - config property value to convert
    * @param {Boolean} [returnObject=false] - returned value should be an array of objects
    * @param {Boolean} [returnObject=false] - returned value should be an array of objects
    * @returns {Number|Object[]}
    * @returns {Number|Object[]}

+ 6 - 0
ambari-web/app/models/service_config.js

@@ -272,6 +272,12 @@ App.ServiceConfigProperty = Em.Object.extend({
     var supportsFinal = this.get('supportsFinal');
     var supportsFinal = this.get('supportsFinal');
     var isFinal = this.get('isFinal');
     var isFinal = this.get('isFinal');
     var defaultIsFinal = this.get('defaultIsFinal');
     var defaultIsFinal = this.get('defaultIsFinal');
+    // ignore precision difference for configs with type of `float` which value may ends with 0
+    // e.g. between 0.4 and 0.40
+    if (this.get('stackConfigProperty') && this.get('stackConfigProperty.valueAttributes.type') == 'float') {
+      defaultValue = '' + parseFloat(defaultValue);
+      value = '' + parseFloat(value);
+    }
     return (defaultValue != null && value !== defaultValue) || (supportsFinal && isFinal !== defaultIsFinal);
     return (defaultValue != null && value !== defaultValue) || (supportsFinal && isFinal !== defaultIsFinal);
   }.property('value', 'defaultValue', 'isEditable', 'isFinal', 'defaultIsFinal'),
   }.property('value', 'defaultValue', 'isEditable', 'isFinal', 'defaultIsFinal'),
 
 

+ 8 - 4
ambari-web/app/views/common/configs/widgets/list_config_widget_view.js

@@ -136,7 +136,7 @@ App.ListConfigWidgetView = App.ConfigWidgetView.extend({
       options.pushObject(configOption.create({
       options.pushObject(configOption.create({
         value: entryValue.value,
         value: entryValue.value,
         label: entryValue.label || entryValue.value,
         label: entryValue.label || entryValue.value,
-        description: entryValue.description
+        description: entryValue.description || ''
       }));
       }));
     });
     });
     this.set('options', options);
     this.set('options', options);
@@ -202,8 +202,8 @@ App.ListConfigWidgetView = App.ConfigWidgetView.extend({
    */
    */
   parseCardinality: function () {
   parseCardinality: function () {
     var cardinality = this.get('config.stackConfigProperty.valueAttributes.selection_cardinality');
     var cardinality = this.get('config.stackConfigProperty.valueAttributes.selection_cardinality');
-    this.set('allowedToSelect', numberUtils.getCardinalityValue(cardinality, true));
-    this.set('neededToSelect', numberUtils.getCardinalityValue(cardinality, false));
+    this.set('allowedToSelect', numberUtils.getCardinalityValue(cardinality, true) || 1);
+    this.set('neededToSelect', numberUtils.getCardinalityValue(cardinality, false) || 1);
   },
   },
 
 
   /**
   /**
@@ -233,12 +233,16 @@ App.ListConfigWidgetView = App.ConfigWidgetView.extend({
   },
   },
 
 
   /**
   /**
-   * Just a small checkbox-wrapper with improved click-handler
+   * Just a small checkbox-wrapper with modified click-handler
    * Should call <code>parentView.toggleOption</code>
    * Should call <code>parentView.toggleOption</code>
    * User may click on the checkbox or on the link which wraps it, but action in both cases should be the same (<code>toggleOption</code>)
    * User may click on the checkbox or on the link which wraps it, but action in both cases should be the same (<code>toggleOption</code>)
    * @type {Em.Checkbox}
    * @type {Em.Checkbox}
    */
    */
   checkBoxWithoutAction: Em.Checkbox.extend({
   checkBoxWithoutAction: Em.Checkbox.extend({
+    init: function() {
+      this._super();
+      this.off('change', this, this._updateElementValue);
+    },
     _updateElementValue: function () {
     _updateElementValue: function () {
       var option = this.get('parentView.options').findProperty('value', this.get('value'));
       var option = this.get('parentView.options').findProperty('value', this.get('value'));
       this.get('parentView').toggleOption({context: option});
       this.get('parentView').toggleOption({context: option});

+ 1 - 1
ambari-web/app/views/common/controls_view.js

@@ -67,7 +67,7 @@ App.SupportsDependentConfigs = Ember.Mixin.create({
    */
    */
   keyUp: function() {
   keyUp: function() {
     if (App.get('supports.enhancedConfigs')) {
     if (App.get('supports.enhancedConfigs')) {
-      this.get('controller').removeCurrentFromDependentList(this.get('serviceConfig'));
+      this.get('controller').removeCurrentFromDependentList(this.get('serviceConfig') || this.get('config'));
     }
     }
   },
   },
 
 

+ 25 - 5
ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js

@@ -33,11 +33,31 @@ describe('App.ListConfigWidgetView', function () {
         stackConfigProperty: Em.Object.create({
         stackConfigProperty: Em.Object.create({
           valueAttributes: {
           valueAttributes: {
             entries: [
             entries: [
-              {value: '1', label: 'first label', description: '1'},
-              {value: '2', label: 'second label', description: '2'},
-              {value: '3', label: 'third label', description: '3'},
-              {value: '4', label: '4th label', description: '4'},
-              {value: '5', label: '5th label', description: '5'}
+              {
+                value: '1',
+                label: 'first label',
+                description: '1'
+              },
+              {
+                value: '2',
+                label: 'second label',
+                description: '2'
+              },
+              {
+                value: '3',
+                label: 'third label',
+                description: '3'
+              },
+              {
+                value: '4',
+                label: '4th label',
+                description: '4'
+              },
+              {
+                value: '5',
+                label: '4th label',
+                description: '5'
+              }
             ],
             ],
             selection_cardinality: '3'
             selection_cardinality: '3'
           }
           }