ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-10242 Overriding property affects other properties overrided earlier. (ababiichuk)
Date Fri, 27 Mar 2015 16:58:15 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk bfb586d85 -> 250c24399


AMBARI-10242 Overriding property affects other properties overrided earlier. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/250c2439
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/250c2439
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/250c2439

Branch: refs/heads/trunk
Commit: 250c24399d3490a7bfcdc1ddbc9ac561e27c612a
Parents: bfb586d
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Fri Mar 27 18:55:26 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Fri Mar 27 18:55:26 2015 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 54 +++++++++++---------
 .../main/service/info/config_test.js            | 13 +++--
 2 files changed, 39 insertions(+), 28 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/250c2439/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 19179a0..670d06e 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -1120,16 +1120,18 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
   setValuesForOverrides: function (overrides, _serviceConfigProperty, serviceConfigProperty,
defaultGroupSelected) {
     if (Em.isNone(overrides)) return;
     overrides.forEach(function (override) {
-      var newSCP = this.createNewSCP(override, _serviceConfigProperty, serviceConfigProperty,
defaultGroupSelected);
-      var parentOverridesArray = serviceConfigProperty.get('overrides');
-      if (parentOverridesArray == null) {
-        parentOverridesArray = Em.A([]);
-        serviceConfigProperty.set('overrides', parentOverridesArray);
+      if (defaultGroupSelected || (Em.get(override, 'group') && this.get('selectedConfigGroup.name')
=== Em.get(override, 'group.name'))) {
+        var newSCP = this.createNewSCP(override, _serviceConfigProperty, serviceConfigProperty,
defaultGroupSelected);
+        var parentOverridesArray = serviceConfigProperty.get('overrides');
+        if (parentOverridesArray == null) {
+          parentOverridesArray = Em.A([]);
+          serviceConfigProperty.set('overrides', parentOverridesArray);
+        }
+        parentOverridesArray.pushObject(newSCP);
+        serviceConfigProperty.set('overrideValues', parentOverridesArray.mapProperty('value'));
+        serviceConfigProperty.set('overrideIsFinalValues', parentOverridesArray.mapProperty('isFinal'));
+        console.debug("createOverrideProperty(): Added override to main-property:", serviceConfigProperty.get('name'));
       }
-      parentOverridesArray.pushObject(newSCP);
-      serviceConfigProperty.set('overrideValues', parentOverridesArray.mapProperty('value'));
-      serviceConfigProperty.set('overrideIsFinalValues', parentOverridesArray.mapProperty('isFinal'));
-      console.debug("createOverrideProperty(): Added override to main-property:", serviceConfigProperty.get('name'));
     }, this);
   },
 
@@ -1148,8 +1150,9 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
     newSCP.set('supportsFinal', serviceConfigProperty.get('supportsFinal'));
     newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
     newSCP.set('parentSCP', serviceConfigProperty);
+    newSCP.set('overrides', null);
+    newSCP.set('group', Em.get(override, 'group'));
     if (defaultGroupSelected) {
-      newSCP.set('group', override.group);
       newSCP.set('isEditable', false);
     }
     return newSCP;
@@ -2591,20 +2594,23 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * @method addOverrideProperty
    */
   addOverrideProperty: function (serviceConfigProperty, group, value) {
-    var overrides = serviceConfigProperty.get('overrides');
-    if (!overrides) {
-      overrides = [];
-      serviceConfigProperty.set('overrides', overrides);
-    }
-    // create new override with new value
-    var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
-    newSCP.set('value', value || '');
-    newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
-    newSCP.set('parentSCP', serviceConfigProperty);
-    newSCP.set('isEditable', true);
-    newSCP.set('group', group);
-    console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty);
-    overrides.pushObject(newSCP);
+    if (serviceConfigProperty.get('isOriginalSCP')) {
+      var overrides = serviceConfigProperty.get('overrides');
+      if (!overrides) {
+        overrides = [];
+        serviceConfigProperty.set('overrides', overrides);
+      }
+      // create new override with new value
+      var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
+      newSCP.set('value', value || '');
+      newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
+      newSCP.set('parentSCP', serviceConfigProperty);
+      newSCP.set('isEditable', true);
+      newSCP.set('group', group);
+      newSCP.set('overrides', null);
+      console.debug("createOverrideProperty(): Added:", newSCP, " to main-property:", serviceConfigProperty);
+      overrides.pushObject(newSCP);
+    }
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/250c2439/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 9614e3a..e8a6e83 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -182,12 +182,13 @@ describe("App.MainServiceInfoConfigsController", function () {
 
   describe("#addOverrideProperty", function () {
     var serviceConfigProperty = Em.Object.create({
-      overrides: []
+      overrides: [],
+      isOriginalSCP: true
     });
 
     var group = {};
     var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
-    newSCP.set('value', '');
+    newSCP.set('value', '1');
     newSCP.set('isOriginalSCP', false);
     newSCP.set('parentSCP', serviceConfigProperty);
     newSCP.set('isEditable', true);
@@ -195,8 +196,12 @@ describe("App.MainServiceInfoConfigsController", function () {
 
 
     it("add new overridden property", function () {
-      mainServiceInfoConfigsController.addOverrideProperty(serviceConfigProperty, group);
-      expect(serviceConfigProperty.get("overrides")[0]).to.eql(newSCP);
+      mainServiceInfoConfigsController.addOverrideProperty(serviceConfigProperty, group,
'1');
+      expect(serviceConfigProperty.get("overrides")[0].get('name')).to.equal(newSCP.get('name'));
+      expect(serviceConfigProperty.get("overrides")[0].get('isOriginalSCP')).to.be.false;
+      expect(serviceConfigProperty.get("overrides")[0].get('isEditable')).to.be.true;
+      expect(serviceConfigProperty.get("overrides")[0].get('group')).to.eql({});
+      expect(serviceConfigProperty.get("overrides")[0].get('parentSCP')).to.eql(serviceConfigProperty);
     });
   });
 


Mime
View raw message