Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id C5246200CD2 for ; Thu, 27 Jul 2017 14:58:57 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id C3E4E16A247; Thu, 27 Jul 2017 12:58:57 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 1EFF516A217 for ; Thu, 27 Jul 2017 14:58:56 +0200 (CEST) Received: (qmail 29999 invoked by uid 500); 27 Jul 2017 12:58:56 -0000 Mailing-List: contact commits-help@ambari.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: ambari-dev@ambari.apache.org Delivered-To: mailing list commits@ambari.apache.org Received: (qmail 29981 invoked by uid 99); 27 Jul 2017 12:58:56 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 27 Jul 2017 12:58:56 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 64F43E973B; Thu, 27 Jul 2017 12:58:55 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jonathanhurley@apache.org To: commits@ambari.apache.org Date: Thu, 27 Jul 2017 12:58:56 -0000 Message-Id: <2a2b6cd589f14a2ba99e40c03f48364f@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [2/6] ambari git commit: AMBARI-21571 Making changes to a config group is forcing updates to other values which customer do not intend to change. (atkach) archived-at: Thu, 27 Jul 2017 12:58:57 -0000 AMBARI-21571 Making changes to a config group is forcing updates to other values which customer do not intend to change. (atkach) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7756f98d Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7756f98d Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7756f98d Branch: refs/heads/branch-2.6 Commit: 7756f98d2f7997dc0ff968ffbe4032d7c2ee9e8a Parents: 7fb0436 Author: Andrii Tkach Authored: Tue Jul 25 16:15:47 2017 +0300 Committer: Andrii Tkach Committed: Wed Jul 26 12:14:47 2017 +0300 ---------------------------------------------------------------------- .../mixins/common/configs/enhanced_configs.js | 23 ++++++++-- .../common/configs/enhanced_configs_test.js | 44 ++++++++++++++++++++ 2 files changed, 64 insertions(+), 3 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7756f98d/ambari-web/app/mixins/common/configs/enhanced_configs.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/common/configs/enhanced_configs.js b/ambari-web/app/mixins/common/configs/enhanced_configs.js index e86fb59..5668b8c 100644 --- a/ambari-web/app/mixins/common/configs/enhanced_configs.js +++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js @@ -392,10 +392,10 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP var self = this; var recommendations = event ? this.get('changedProperties') : this.get('recommendations'), recommendedChanges = recommendations.filterProperty('isEditable'), - requiredChanges = recommendations.filterProperty('isEditable', false); - if (recommendations.length > 0) { + requiredChanges = this.filterRequiredChanges(recommendations); + if (recommendedChanges.length > 0 || requiredChanges.length > 0) { App.showDependentConfigsPopup(recommendedChanges, requiredChanges, function() { - self.onSaveRecommendedPopup(recommendations); + self.onSaveRecommendedPopup(recommendedChanges.concat(requiredChanges)); if (callback) callback(); }, secondary); } else { @@ -404,6 +404,23 @@ App.EnhancedConfigsMixin = Em.Mixin.create(App.ConfigWithOverrideRecommendationP }, /** + * + * @param {Array} recommendations + * @returns {Array} + */ + filterRequiredChanges: function(recommendations) { + return recommendations.filter(function(recommendation) { + if (recommendation.isEditable === false) { + if (!this.get('selectedConfigGroup.isDefault')) { + return App.ServiceConfigGroup.defaultGroupName !== recommendation.configGroup + } else { + return true; + } + } + }, this); + }, + + /** * update configs when toggle checkbox on dependent configs popup */ onSaveRecommendedPopup: function(recommendations) { http://git-wip-us.apache.org/repos/asf/ambari/blob/7756f98d/ambari-web/test/mixins/common/configs/enhanced_configs_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js index 880f4d2..3a41dc9 100644 --- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js +++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js @@ -263,5 +263,49 @@ describe('App.EnhancedConfigsMixin', function() { )).to.be.true; }); }); + + describe('#filterRequiredChanges', function() { + + it('all recommendations editable', function() { + var recommendations = [ + { + isEditable: true + } + ]; + expect(instanceObject.filterRequiredChanges(recommendations)).to.be.empty; + }); + + it('recommendations not editable when editing default config group', function() { + instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: true})); + var recommendations = [ + { + isEditable: false + } + ]; + expect(instanceObject.filterRequiredChanges(recommendations)).to.be.eql(recommendations); + }); + + it('recommendations not editable when editing non-default config group for default group', function() { + instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: false})); + var recommendations = [ + { + isEditable: false, + configGroup: App.ServiceConfigGroup.defaultGroupName + } + ]; + expect(instanceObject.filterRequiredChanges(recommendations)).to.be.empty; + }); + + it('recommendations not editable when editing non-default config group for non-default group', function() { + instanceObject.set('selectedConfigGroup', Em.Object.create({isDefault: false})); + var recommendations = [ + { + isEditable: false, + configGroup: 'g1' + } + ]; + expect(instanceObject.filterRequiredChanges(recommendations)).to.be.eql(recommendations); + }); + }); });