Repository: ambari Updated Branches: refs/heads/trunk 4c27db624 -> 204dc8ddf
AMBARI-12575 UI should allow to set same values for config and it's override without any errors. (ababiicuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/204dc8dd Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/204dc8dd Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/204dc8dd Branch: refs/heads/trunk Commit: 204dc8ddf8aaccbd6518112620fb1de9eb1187b6 Parents: 4c27db6 Author: aBabiichuk <[email protected]> Authored: Wed Jul 29 14:02:58 2015 +0300 Committer: aBabiichuk <[email protected]> Committed: Wed Jul 29 14:05:17 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/messages.js | 1 - .../configs/objects/service_config_property.js | 72 +--------- .../objects/service_config_property_test.js | 136 ------------------- .../widgets/list_config_widget_view_test.js | 17 --- 4 files changed, 1 insertion(+), 225 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/204dc8dd/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 3cff8b6..8f21699 100644 --- a/ambari-web/app/messages.js +++ b/ambari-web/app/messages.js @@ -409,7 +409,6 @@ Em.I18n.translations = { 'users.userName.validationFail': 'Only lowercase letters and numbers are recommended; must start with a letter', 'host.spacesValidation': 'Cannot contain whitespace', 'host.trimspacesValidation': 'Cannot contain leading or trailing whitespace', - 'config.override.valueEqualToParentConfig': 'Configuration overrides must have different value', 'services.hdfs.rebalance.title' : 'HDFS Rebalance', 'services.ganglia.description':'Ganglia Metrics Collection system', http://git-wip-us.apache.org/repos/asf/ambari/blob/204dc8dd/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 db09678..b259f56 100644 --- a/ambari-web/app/models/configs/objects/service_config_property.js +++ b/ambari-web/app/models/configs/objects/service_config_property.js @@ -462,10 +462,6 @@ App.ServiceConfigProperty = Em.Object.extend({ } } - if (!isError) { - isError = this._validateOverrides(); - } - if (!isWarn || isError) { // Errors get priority this.set('warnMessage', ''); this.set('warn', false); @@ -479,72 +475,6 @@ App.ServiceConfigProperty = Em.Object.extend({ } else { this.set('error', true); } - }.observes('value', 'isFinal', 'retypedPassword'), - - /** - * Check config overrides and parent config overrides (if exist) - * @returns {boolean} - * @private - * @method _validateOverrides - */ - _validateOverrides: function () { - var isError = false; - var value = this._getValueForCheck(this.get('value')); - var isOriginalSCP = this.get('isOriginalSCP'); - var supportsFinal = this.get('supportsFinal'); - var isFinal = this.get('isFinal'); - var parentSCP = this.get('parentSCP'); - var overrides = this.get('overrides'); - if (isOriginalSCP) { - if (overrides) { - overrides.forEach(function (override) { - if (value === this._getValueForCheck(override.get('value'))) { - if (supportsFinal) { - if (isFinal === override.get('isFinal')) { - this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig')); - isError = true; - } - } - else { - this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig')); - isError = true; - } - } - }, this); - } - } else { - if (!Em.isNone(parentSCP) && value === this._getValueForCheck(parentSCP.get('value'))) { - if (supportsFinal) { - if (isFinal === parentSCP.get('isFinal')) { - this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig')); - isError = true; - } - } - else { - this.set('errorMessage', Em.I18n.t('config.override.valueEqualToParentConfig')); - isError = true; - } - } - } - return isError; - }, - - /** - * Some values should be little bit changed before checking for overrides values - * `directories`-values should be "trimmed" for multiple mew-line symbols - * @param {string} value - * @returns {string} - * @private - */ - _getValueForCheck: function (value) { - value = '' + value; - switch(this.get('displayType')) { - case 'directories': - return value.replace(/(\n\r?)+/g, '\n').trim(); - break; - default: - return value; - } - } + }.observes('value', 'isFinal', 'retypedPassword') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/204dc8dd/ambari-web/test/models/configs/objects/service_config_property_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/models/configs/objects/service_config_property_test.js b/ambari-web/test/models/configs/objects/service_config_property_test.js index 00cf620..3ec078b 100644 --- a/ambari-web/test/models/configs/objects/service_config_property_test.js +++ b/ambari-web/test/models/configs/objects/service_config_property_test.js @@ -475,116 +475,6 @@ describe('App.ServiceConfigProperty', function () { }); }); - describe('#_validateOverrides', function () { - - Em.A([ - { - m: 'original config', - e: false, - c: { - value: 'on', - isOriginalSCP: true, - supportsFinal: false, - isFinal: false, - parentSCP: null - } - }, - { - m: 'not original config, value equal to parent', - e: true, - c: { - value: 'on', - isOriginalSCP: false, - supportsFinal: false, - isFinal: false, - parentSCP: App.ServiceConfigProperty.create({ - value: 'on' - }) - } - }, - { - m: 'not original config, isFinal equal to parent', - e: false, - c: { - value: 'on', - isOriginalSCP: false, - supportsFinal: true, - isFinal: false, - parentSCP: App.ServiceConfigProperty.create({ - value: 'off', - isFinal: false - }) - } - }, - { - m: 'not original config, isFinal equal to parent, but final not supported', - e: false, - c: { - value: 'on', - isOriginalSCP: false, - supportsFinal: false, - isFinal: false, - parentSCP: App.ServiceConfigProperty.create({ - value: 'off', - isFinal: false - }) - } - }, - { - m: 'not original config, parent override doesn\'t have same value', - e: false, - c: { - value: 'on', - isOriginalSCP: false, - supportsFinal: true, - isFinal: false, - parentSCP: App.ServiceConfigProperty.create({ - value: 'off', - isFinal: true, - overrides: [ - App.ServiceConfigProperty.create({ - value: 'another', - isOriginalSCP: false - }) - ] - }) - } - }, - { - m: '`directories`-config with almost equal value', - e: true, - c: { - value: "/hadoop/hdfs/data\n\n", - displayType: 'directories', - supportsFinal: false, - isOriginalSCP: false, - parentSCP: App.ServiceConfigProperty.create({ - value: "/hadoop/hdfs/data\n" - }) - } - }, - { - m: '`directories`-config with almost equal value (2)', - e: true, - c: { - value: "/hadoop/hdfs/data", - displayType: 'directories', - supportsFinal: false, - isOriginalSCP: false, - parentSCP: App.ServiceConfigProperty.create({ - value: "/hadoop/hdfs/data\n" - }) - } - } - ]).forEach(function (test) { - it(test.m, function () { - serviceConfigProperty.reopen(test.c); - expect(serviceConfigProperty._validateOverrides()).to.equal(test.e); - }); - }); - - }); - describe('#undoAvailable', function () { Em.A([ @@ -620,32 +510,6 @@ describe('App.ServiceConfigProperty', function () { }); - describe('#_getValueForCheck', function () { - - beforeEach(function () { - serviceConfigProperty.setProperties({ - value: "/hadoop/hdfs/data\n", - displayType: 'directories', - supportsFinal: false, - isOriginalSCP: true, - overrides: [ - Em.Object.create({ - value: "/hadoop/hdfs/data\n\n" - }) - ] - }); - }); - - it('should trim value', function () { - expect(serviceConfigProperty._getValueForCheck(serviceConfigProperty.get('value'))).to.equal('/hadoop/hdfs/data'); - }); - - it('should trim value 2', function () { - expect(serviceConfigProperty._getValueForCheck(serviceConfigProperty.get('overrides.0.value'))).to.equal('/hadoop/hdfs/data'); - }); - - }); - describe('#overrideIsFinalValues', function () { it('should be defined as empty array', function () { expect(serviceConfigProperty.get('overrideIsFinalValues')).to.eql([]); http://git-wip-us.apache.org/repos/asf/ambari/blob/204dc8dd/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js index 3db2dcb..d72e38e 100644 --- a/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js +++ b/ambari-web/test/views/common/configs/widgets/list_config_widget_view_test.js @@ -26,8 +26,6 @@ describe('App.ListConfigWidgetView', function () { view = App.ListConfigWidgetView.create({ initPopover: Em.K, config: Em.Object.create({ - _validateOverrides: App.ServiceConfigProperty.prototype._validateOverrides, - _getValueForCheck: App.ServiceConfigProperty.prototype._getValueForCheck, validate: App.ServiceConfigProperty.prototype.validate, name: 'a.b.c', savedValue: '2,1', @@ -194,21 +192,6 @@ describe('App.ListConfigWidgetView', function () { view.get('options').setEach('isSelected', true); expect(view.get('config.errorMessage')).to.equal(''); }); - - it('check override', function () { - - view.get('config').setProperties({ - isOriginalSCP: false, - parentSCP: Em.Object.create({ - value: '2,1', - isFinal: false - }) - }); - view.checkSelectedItemsCount(); - expect(view.get('config.errorMessage')).to.equal(Em.I18n.t('config.override.valueEqualToParentConfig')); - - }); - }); });
