Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 1ace68bf1 -> 0f0e4f42f


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


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

Branch: refs/heads/branch-2.4
Commit: 0f0e4f42fe45f79fca3fb479a160b81ceedbb54c
Parents: 1ace68b
Author: ababiichuk <[email protected]>
Authored: Thu May 19 16:52:13 2016 +0300
Committer: ababiichuk <[email protected]>
Committed: Thu May 19 17:45:30 2016 +0300

----------------------------------------------------------------------
 .../configs/stack_config_properties_mapper.js   | 14 +++++++++-
 .../stack_config_properties_mapper_test.js      | 27 ++++++++++++++++++++
 2 files changed, 40 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/0f0e4f42/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js 
b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 5c34f62..2c8959d 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/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;
@@ -158,6 +158,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
    * @param {Object} config

http://git-wip-us.apache.org/repos/asf/ambari/blob/0f0e4f42/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js 
b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
index dbe0ece..196e682 100644
--- a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
+++ b/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);
+        })
+      });
+  });
+
 });

Reply via email to