AMBARI-14917. Edit WEB Alert issues (onechiporenko)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/74d5a016 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/74d5a016 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/74d5a016 Branch: refs/heads/branch-dev-patch-upgrade Commit: 74d5a016711c8c9d8641953e8732e65534db1a88 Parents: 3d7643b Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Thu Feb 4 14:13:28 2016 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Fri Feb 5 10:02:36 2016 +0200 ---------------------------------------------------------------------- .../alerts/definition_configs_controller.js | 13 +++++----- ambari-web/app/models/alerts/alert_config.js | 1 + ambari-web/app/styles/alerts.less | 2 +- .../activateStandby/step2_controller_test.js | 1 - .../definitions_configs_controller_test.js | 26 ++++++++++++++++++++ 5 files changed, 34 insertions(+), 9 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/74d5a016/ambari-web/app/controllers/main/alerts/definition_configs_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js index 3fd5510..ec5680c 100644 --- a/ambari-web/app/controllers/main/alerts/definition_configs_controller.js +++ b/ambari-web/app/controllers/main/alerts/definition_configs_controller.js @@ -499,12 +499,8 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({ return c.get('name') !== 'parameter'; }); configs.forEach(function (property) { - var apiProperties = property.get('apiProperty'); - var apiFormattedValues = property.get('apiFormattedValue'); - if (!Em.isArray(property.get('apiProperty'))) { - apiProperties = [property.get('apiProperty')]; - apiFormattedValues = [property.get('apiFormattedValue')]; - } + var apiProperties = Em.makeArray(property.get('apiProperty')); + var apiFormattedValues = Em.makeArray(property.get('apiFormattedValue')); apiProperties.forEach(function (apiProperty, i) { if (apiProperty.contains('source.')) { if (!propertiesToUpdate['AlertDefinition/source']) { @@ -531,7 +527,6 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({ } Ember.setFullPath(propertiesToUpdate['AlertDefinition/source'], apiProperty.replace('source.', ''), apiFormattedValues[i]); } - } else { if (apiProperty) { @@ -541,6 +536,10 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({ }, this); }, this); + if (Em.get(propertiesToUpdate, 'AlertDefinition/source.uri.id')) { + delete propertiesToUpdate['AlertDefinition/source'].uri.id; + } + // `source.parameters` is an array and should be updated separately from other configs if (this.get('content.parameters.length')) { propertiesToUpdate['AlertDefinition/source/parameters'] = this.get('content.rawSourceData.parameters'); http://git-wip-us.apache.org/repos/asf/ambari/blob/74d5a016/ambari-web/app/models/alerts/alert_config.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/models/alerts/alert_config.js b/ambari-web/app/models/alerts/alert_config.js index a9a8154..c86b19a 100644 --- a/ambari-web/app/models/alerts/alert_config.js +++ b/ambari-web/app/models/alerts/alert_config.js @@ -437,6 +437,7 @@ App.AlertConfigProperties = { displayType: 'textField', classNames: 'alert-connection-timeout', apiProperty: 'source.uri.connection_timeout', + unit: 'Seconds', isValid: function () { var value = this.get('value'); return numericUtils.isPositiveNumber(value); http://git-wip-us.apache.org/repos/asf/ambari/blob/74d5a016/ambari-web/app/styles/alerts.less ---------------------------------------------------------------------- diff --git a/ambari-web/app/styles/alerts.less b/ambari-web/app/styles/alerts.less index 1063ecf..c4f163d 100644 --- a/ambari-web/app/styles/alerts.less +++ b/ambari-web/app/styles/alerts.less @@ -324,7 +324,7 @@ padding-right: 13px; } - .alert-interval-input { + .alert-interval-input, .alert-connection-timeout { input { width: 20%; } http://git-wip-us.apache.org/repos/asf/ambari/blob/74d5a016/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js index e702892..845c932 100644 --- a/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js +++ b/ambari-web/test/controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller_test.js @@ -18,7 +18,6 @@ var App = require('app'); require('controllers/main/admin/highAvailability/hawq/activateStandby/step2_controller'); -var testHelpers = require('test/helpers'); describe('App.ActivateHawqStandbyWizardStep2Controller', function () { http://git-wip-us.apache.org/repos/asf/ambari/blob/74d5a016/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js index 4061f35..c957efd 100644 --- a/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js +++ b/ambari-web/test/controllers/main/alerts/definitions_configs_controller_test.js @@ -482,6 +482,32 @@ describe('App.MainAlertDefinitionConfigsController', function () { }); }); + describe('Some fields should be removed', function () { + + beforeEach(function () { + controller.set('content', Em.Object.create({ + rawSourceData: { + uri: { + id: 123 + } + } + })); + controller.set('configs', [ + Em.Object.create({ + apiProperty: 'source.uri.connection_timeout', + apiFormattedValue: 123, + wasChanged: true + }) + ]); + this.result = controller.getPropertiesToUpdate(); + }); + + it('`AlertDefinition/source.uri.id`', function () { + expect(this.result).to.not.have.deep.property('AlertDefinition/source.uri.id'); + }); + + }); + describe('`source/parameters` for SCRIPT configs', function () { beforeEach(function () {