Repository: ambari Updated Branches: refs/heads/trunk 6a03b3381 -> 785dd318f
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/785dd318 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/785dd318 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/785dd318 Branch: refs/heads/trunk Commit: 785dd318ff42a8d934f0bce394bdf3da4125f4f8 Parents: 6a03b33 Author: ababiichuk <[email protected]> Authored: Thu May 19 16:52:13 2016 +0300 Committer: ababiichuk <[email protected]> Committed: Thu May 19 17:44:36 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/785dd318/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/785dd318/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); + }) + }); + }); + });
