瀏覽代碼

AMBARI-16773 hbase_principal_name and hbase_user_keytab fields have strange behaviour.(ababiichuk)

ababiichuk 9 年之前
父節點
當前提交
0f0e4f42fe

+ 13 - 1
ambari-web/app/mappers/configs/stack_config_properties_mapper.js

@@ -85,7 +85,7 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
 
           var attributes = config.StackConfigurations.property_value_attributes;
           if (attributes) {
-            config.is_required = !attributes.empty_value_valid;
+            config.is_required = this._isRequired(attributes.empty_value_valid, config.StackConfigurations.property_value);
             config.is_reconfigurable = !(attributes.editable_only_at_install || config.StackConfigurations.type === 'cluster-env.xml');
             config.is_editable = !attributes.read_only;
             config.is_required_by_agent = !attributes.ui_only_property;
@@ -157,6 +157,18 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
 
   /******************* METHODS TO MERGE STACK PROPERTIES WITH STORED ON UI *********************************/
 
+  /**
+   * Config should not be required if value from stack is null
+   *
+   * @param allowEmpty
+   * @param propertyValue
+   * @returns {*|boolean}
+   * @private
+   */
+  _isRequired: function (allowEmpty, propertyValue) {
+    return !allowEmpty && !Em.isNone(propertyValue);
+  },
+
   /**
    * find UI config with current name and fileName
    * if there is such property - adds some info to config object

+ 27 - 0
ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js

@@ -274,4 +274,31 @@ describe.skip('App.stackConfigPropertiesMapper', function () {
     });
   });
 
+  describe('#_isRequired', function() {
+    [
+      {
+        allow_empty: true,
+        property_value: 'some',
+        is_required: false,
+        message: 'false for value "some" and "allow_empty" true'
+      },
+      {
+        allow_empty: false,
+        property_value: '',
+        is_required: true,
+        message: 'true for value "" and "allow_empty" false'
+      },
+      {
+        allow_empty: false,
+        property_value: null,
+        is_required: false,
+        message: 'false for value null" and "allow_empty" false'
+      }
+    ].forEach(function(c) {
+        it(c.message, function() {
+          expect(App.stackConfigPropertiesMapper._isRequired(c.allow_empty, c.property_value)).to.equal(c.is_required);
+        })
+      });
+  });
+
 });