AMBARI-21848. Ambari Replaces the Value of Undefined Service Configuration Properties with "Undefined" in Default Config Group If the Same Property is Defined in Different Config Group (akovalenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/3f083249 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/3f083249 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/3f083249 Branch: refs/heads/feature-branch-AMBARI-21307 Commit: 3f08324907e70a4b6d09cd4d6aa0d35c9dfbb9e3 Parents: 9603735 Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Wed Aug 30 16:58:53 2017 +0300 Committer: Aleksandr Kovalenko <akovale...@hortonworks.com> Committed: Wed Aug 30 18:03:40 2017 +0300 ---------------------------------------------------------------------- ambari-web/app/mixins/common/configs/configs_saver.js | 4 ++-- .../app/models/configs/objects/service_config.js | 4 ++-- .../models/configs/objects/service_config_property.js | 8 ++++++++ .../common/configs/overriddenPropertyRow_view.js | 3 +++ .../models/configs/objects/service_config_test.js | 14 +++++++++++++- 5 files changed, 28 insertions(+), 5 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/3f083249/ambari-web/app/mixins/common/configs/configs_saver.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/configs_saver.js b/ambari-web/app/mixins/common/configs/configs_saver.js index dafee79..f11cdd0 100644 --- a/ambari-web/app/mixins/common/configs/configs_saver.js +++ b/ambari-web/app/mixins/common/configs/configs_saver.js @@ -327,9 +327,9 @@ App.ConfigsSaverMixin = Em.Mixin.create({ return App.config.getOriginalFileName(type); }); - // save modified original configs that have no group + // save modified original configs that have no group and are not Undefined label modifiedConfigs = this.saveSiteConfigs(modifiedConfigs.filter(function (config) { - return !config.get('group'); + return !config.get('group') && !config.get('isUndefinedLabel'); })); if (!Em.isArray(modifiedConfigs) || modifiedConfigs.length == 0) return null; http://git-wip-us.apache.org/repos/asf/ambari/blob/3f083249/ambari-web/app/models/configs/objects/service_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config.js b/ambari-web/app/models/configs/objects/service_config.js index ea24ec4..608e99e 100644 --- a/ambari-web/app/models/configs/objects/service_config.js +++ b/ambari-web/app/models/configs/objects/service_config.js @@ -60,12 +60,12 @@ App.ServiceConfig = Ember.Object.extend({ setActiveProperties: function() { Em.run.once(this, 'setActivePropertiesOnce'); - }.observes('configs.@each.isActive', 'configs.@each.isRequiredByAgent', 'configs.@each.value'), + }.observes('configs.@each.isActive', 'configs.@each.isRequiredByAgent', 'configs.@each.value', 'configs.@each.isUndefinedLabel'), setActivePropertiesOnce: function() { if (this.get('isDestroyed')) return false; var activeProperties = this.get('configs').filter(function(c) { - return c.get('isActive') && (c.get('isRequiredByAgent') || c.get('isRequired')); + return (c.get('isActive') || c.get('isUndefinedLabel')) && (c.get('isRequiredByAgent') || c.get('isRequired')); }); this.set('activeProperties', activeProperties); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/3f083249/ambari-web/app/models/configs/objects/service_config_property.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/configs/objects/service_config_property.js b/ambari-web/app/models/configs/objects/service_config_property.js index 5d306eb..f8ca8a7 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/ambari-web/app/models/configs/objects/service_config_property.js @@ -167,6 +167,14 @@ App.ServiceConfigProperty = Em.Object.extend({ */ isCustomGroupConfig: false, + /** + * Determines if config is Undefined label, used for overrides, that do not have original property in default group + * @type {boolean} + */ + isUndefinedLabel: function () { + return this.get('displayType') === 'label' && this.get('value') === 'Undefined'; + }.property('displayType', 'value'), + error: Em.computed.bool('errorMessage.length'), warn: Em.computed.bool('warnMessage.length'), hasValidationErrors: Em.computed.bool('validationErrors.length'), http://git-wip-us.apache.org/repos/asf/ambari/blob/3f083249/ambari-web/app/views/common/configs/overriddenPropertyRow_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/common/configs/overriddenPropertyRow_view.js b/ambari-web/app/views/common/configs/overriddenPropertyRow_view.js index af65aee..96c1fb1 100644 --- a/ambari-web/app/views/common/configs/overriddenPropertyRow_view.js +++ b/ambari-web/app/views/common/configs/overriddenPropertyRow_view.js @@ -85,5 +85,8 @@ App.ServiceConfigView.SCPOverriddenRowsView = Ember.View.extend({ this.get('parentView.categoryConfigsAll').removeObject(scpToBeRemoved); } } + if (scp.get('isUndefinedLabel')) { + scp.set('isVisible', false); + } } }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/3f083249/ambari-web/test/models/configs/objects/service_config_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_test.js b/ambari-web/test/models/configs/objects/service_config_test.js index ad3dbfe..cc01047 100644 --- a/ambari-web/test/models/configs/objects/service_config_test.js +++ b/ambari-web/test/models/configs/objects/service_config_test.js @@ -86,6 +86,18 @@ var serviceConfig, 'isValid': true, 'isRequired': true, 'isValidOverride': false + }), + App.ServiceConfigProperty.create({ + 'name': 'p8', + 'isVisible': false, + 'hiddenBySection': false, + 'hiddenBySubSection': false, + 'isRequiredByAgent': false, + 'isValid': true, + 'isRequired': true, + 'isValidOverride': true, + 'value': 'Undefined', + 'displayType': 'label' }) ]; @@ -100,7 +112,7 @@ describe('App.ServiceConfig', function () { describe('#activeProperties', function() { it('returns collection of properties that should be shown', function() { serviceConfig.setActivePropertiesOnce(); - expect(serviceConfig.get('activeProperties').mapProperty('name')).to.be.eql(['p1','p4','p5','p7']); + expect(serviceConfig.get('activeProperties').mapProperty('name')).to.be.eql(['p1','p4','p5','p7', 'p8']); }); });