You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2017/07/26 09:13:19 UTC
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)
Repository: ambari
Updated Branches:
refs/heads/trunk f58abd481 -> a19cac753
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/a19cac75
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/a19cac75
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/a19cac75
Branch: refs/heads/trunk
Commit: a19cac7536e8e9f10d7a207559794c289d01485d
Parents: f58abd4
Author: Andrii Tkach <at...@apache.org>
Authored: Tue Jul 25 18:24:04 2017 +0300
Committer: Andrii Tkach <at...@apache.org>
Committed: Wed Jul 26 12:12:59 2017 +0300
----------------------------------------------------------------------
.../mixins/common/configs/enhanced_configs.js | 23 ++++++++--
.../common/configs/enhanced_configs_test.js | 48 +++++++++++++++++++-
2 files changed, 66 insertions(+), 5 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/a19cac75/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 8fc7a4c..a5af407 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -464,10 +464,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 {
@@ -476,6 +476,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/a19cac75/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 c0d332c..999ed8c 100644
--- a/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
+++ b/ambari-web/test/mixins/common/configs/enhanced_configs_test.js
@@ -1094,12 +1094,14 @@ describe('App.EnhancedConfigsMixin', function () {
callback();
});
sinon.stub(mixin, 'onSaveRecommendedPopup');
+ sinon.stub(mixin, 'filterRequiredChanges').returns([]);
sinon.stub(mock, 'callback');
});
afterEach(function() {
App.showDependentConfigsPopup.restore();
mixin.onSaveRecommendedPopup.restore();
+ mixin.filterRequiredChanges.restore();
mock.callback.restore();
});
@@ -1110,9 +1112,9 @@ describe('App.EnhancedConfigsMixin', function () {
});
it("onSaveRecommendedPopup should be called", function() {
- mixin.set('recommendations', [{}]);
+ mixin.set('recommendations', [{isEditable: true}]);
mixin.showChangedDependentConfigs(null, mock.callback, Em.K);
- expect(mixin.onSaveRecommendedPopup.calledWith([{}])).to.be.true;
+ expect(mixin.onSaveRecommendedPopup.calledWith([{isEditable: true}])).to.be.true;
expect(mock.callback.calledOnce).to.be.true;
});
});
@@ -1411,6 +1413,48 @@ describe('App.EnhancedConfigsMixin', function () {
});
+ describe('#filterRequiredChanges', function() {
+ it('all recommendations editable', function() {
+ var recommendations = [
+ {
+ isEditable: true
+ }
+ ];
+ expect(mixin.filterRequiredChanges(recommendations)).to.be.empty;
+ });
+
+ it('recommendations not editable when editing default config group', function() {
+ mixin.set('selectedConfigGroup', Em.Object.create({isDefault: true}));
+ var recommendations = [
+ {
+ isEditable: false
+ }
+ ];
+ expect(mixin.filterRequiredChanges(recommendations)).to.be.eql(recommendations);
+ });
+
+ it('recommendations not editable when editing non-default config group for default group', function() {
+ mixin.set('selectedConfigGroup', Em.Object.create({isDefault: false}));
+ var recommendations = [
+ {
+ isEditable: false,
+ configGroup: App.ServiceConfigGroup.defaultGroupName
+ }
+ ];
+ expect(mixin.filterRequiredChanges(recommendations)).to.be.empty;
+ });
+
+ it('recommendations not editable when editing non-default config group for non-default group', function() {
+ mixin.set('selectedConfigGroup', Em.Object.create({isDefault: false}));
+ var recommendations = [
+ {
+ isEditable: false,
+ configGroup: 'g1'
+ }
+ ];
+ expect(mixin.filterRequiredChanges(recommendations)).to.be.eql(recommendations);
+ });
+ });
});