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-15517 Improve config groups loading on wizard (part 1). (ababiichuk)
Date Wed, 23 Mar 2016 11:31:52 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 3ae91d255 -> 7e1815db5


AMBARI-15517 Improve config groups loading on wizard (part 1). (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 7e1815db51adc60b2944b7cf17cf99ac293af84c
Parents: 3ae91d2
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Tue Mar 22 18:14:34 2016 +0200
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Wed Mar 23 13:29:58 2016 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 66 +++------------
 ambari-web/app/utils/config.js                  | 10 ++-
 .../test/controllers/wizard/step7_test.js       | 87 +-------------------
 3 files changed, 22 insertions(+), 141 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7e1815db/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index 9113ea2..1df119e 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -479,18 +479,22 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
 
   loadServiceConfigGroupOverridesSuccess: function (data, opt, params) {
     data.items.forEach(function (config) {
-      var hostOverrideValue, hostOverrideIsFinal;
       var group = params.typeTagToGroupMap[config.type + "///" + config.tag];
       var properties = config.properties;
       for (var prop in properties) {
         var fileName = App.config.getOriginalFileName(config.type);
-        var serviceConfig = !!params.configKeyToConfigMap[fileName] ? params.configKeyToConfigMap[fileName][prop]
: false;
-        if (serviceConfig) {
-          hostOverrideValue = App.config.formatPropertyValue(serviceConfig, properties[prop]);
-          hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final
&& config.properties_attributes.final[prop]);
-          // Value of this property is different for this host.
-          if (!Em.get(serviceConfig, 'overrides')) Em.set(serviceConfig, 'overrides', []);
-          serviceConfig.overrides.pushObject({value: hostOverrideValue, group: group, isFinal:
hostOverrideIsFinal});
+        var serviceConfigProperty = !!params.configKeyToConfigMap[fileName] ? params.configKeyToConfigMap[fileName][prop]
: false;
+        if (serviceConfigProperty) {
+          var hostOverrideValue = App.config.formatPropertyValue(serviceConfigProperty, properties[prop]);
+          var hostOverrideIsFinal = !!(config.properties_attributes && config.properties_attributes.final
&& config.properties_attributes.final[prop]);
+
+          App.config.createOverride(serviceConfigProperty, {
+            "value": hostOverrideValue,
+            "savedValue": hostOverrideValue,
+            "isFinal": hostOverrideIsFinal,
+            "savedIsFinal": hostOverrideIsFinal,
+            "isEditable": false
+          }, group, true);
         } else {
           params.serviceConfigs.push(App.config.createCustomGroupConfig(prop, fileName, config.properties[prop],
group));
         }
@@ -539,51 +543,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
   },
 
   /**
-   * Set <code>overrides</code>-property to <code>serviceConfigProperty<code>
-   * @param {Ember.Object} serviceConfigProperty
-   * @param {Ember.Object} component
-   * @return {Ember.Object} Updated config-object
-   * @method _updateOverridesForConfig
-   */
-  _updateOverridesForConfig: function (serviceConfigProperty, component) {
-
-    var overrides = serviceConfigProperty.get('overrides');
-
-    if (Em.isNone(overrides)) {
-      serviceConfigProperty.set('overrides', Em.A([]));
-      return serviceConfigProperty;
-    }
-    serviceConfigProperty.set('overrides', null);
-    var defaultGroupSelected = component.get('selectedConfigGroup.isDefault');
-
-    // Wrap each override to App.ServiceConfigProperty
-    overrides.forEach(function (override) {
-      var newSCP = App.ServiceConfigProperty.create(serviceConfigProperty);
-      newSCP.set('value', override.value);
-      newSCP.set('isOriginalSCP', false); // indicated this is overridden value,
-      newSCP.set('parentSCP', serviceConfigProperty);
-      if (defaultGroupSelected) {
-        var group = component.get('configGroups').findProperty('name', override.group.get('name'));
-        // prevent cycle in proto object, clean link
-        if (group.get('properties').length == 0) {
-          group.set('properties', Em.A([]));
-        }
-        group.get('properties').push(newSCP);
-        newSCP.set('group', override.group);
-        newSCP.set('isEditable', false);
-      }
-      var parentOverridesArray = serviceConfigProperty.get('overrides');
-      if (Em.isNone(parentOverridesArray)) {
-        parentOverridesArray = Em.A([]);
-        serviceConfigProperty.set('overrides', parentOverridesArray);
-      }
-      serviceConfigProperty.get('overrides').pushObject(newSCP);
-      newSCP.validate();
-    }, this);
-    return serviceConfigProperty;
-  },
-
-  /**
    * Set configs with overrides, recommended defaults to component
    * @param {Ember.Object[]} configs
    * @param {Ember.Object} componentConfig
@@ -602,7 +561,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
       if (!Em.isNone(serviceConfigProperty.get('group'))) {
         serviceConfigProperty.get('group.properties').pushObject(serviceConfigProperty);
       }
-      this._updateOverridesForConfig(serviceConfigProperty, component);
       this._updateIsEditableFlagForConfig(serviceConfigProperty, defaultGroupSelected);
 
       componentConfig.get('configs').pushObject(serviceConfigProperty);

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e1815db/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 8866612..db6c27f 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -893,9 +893,10 @@ App.config = Em.Object.create({
    * @param {App.ServiceConfigProperty} serviceConfigProperty
    * @param {Object} override - plain object with properties that is different from parent
SCP
    * @param {App.ServiceConfigGroup} configGroup
+   * @param {boolean} [updateGroup]
    * @returns {App.ServiceConfigProperty}
    */
-  createOverride: function(serviceConfigProperty, override, configGroup) {
+  createOverride: function(serviceConfigProperty, override, configGroup, updateGroup) {
     Em.assert('serviceConfigProperty can\' be null', serviceConfigProperty);
     Em.assert('configGroup can\' be null', configGroup);
 
@@ -916,6 +917,13 @@ App.config = Em.Object.create({
       'parentSCP': serviceConfigProperty
     });
 
+    if (updateGroup) {
+      if (!configGroup.get('properties.length')) {
+        configGroup.set('properties', Em.A([]));
+      }
+      configGroup.get('properties').push(newOverride);
+    }
+
     serviceConfigProperty.get('overrides').pushObject(newOverride);
     serviceConfigProperty.set('overrideValues', serviceConfigProperty.get('overrides').mapProperty('value'));
     serviceConfigProperty.set('overrideIsFinalValues', serviceConfigProperty.get('overrides').mapProperty('isFinal'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/7e1815db/ambari-web/test/controllers/wizard/step7_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js
index 1291ed9..f1033bb 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -1236,91 +1236,6 @@ describe('App.InstallerStep7Controller', function () {
       });
   });
 
-  describe('#_updateOverridesForConfig', function () {
-
-    it('should set empty array', function () {
-      var serviceConfigProperty = Em.Object.create({
-        overrides: null
-      }), component = Em.Object.create();
-      installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
-      expect(serviceConfigProperty.get('overrides')).to.eql(Em.A([]));
-    });
-
-    describe('host overrides not supported', function () {
-      var serviceConfigProperty = Em.Object.create({
-        overrides: [
-          {value: 'new value'}
-        ]
-      });
-      var component = Em.Object.create({selectedConfigGroup: {isDefault: false}});
-
-      beforeEach(function () {
-        installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
-      });
-      it('there is 1 override', function () {
-        expect(serviceConfigProperty.get('overrides').length).to.equal(1);
-      });
-      it('override value is valid', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
-      });
-      it('override is not original SCP', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
-      });
-      it('override is linked to parent', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
-      });
-    });
-
-    describe('host overrides supported', function () {
-      var serviceConfigProperty;
-      var component;
-      beforeEach(function () {
-        sinon.stub(App, 'get', function (k) {
-          if (k === 'supports.hostOverrides') return true;
-          return Em.get(App, k);
-        });
-        serviceConfigProperty = Em.Object.create({
-          overrides: [
-            {value: 'new value', group: Em.Object.create({name: 'n1'})}
-          ]
-        });
-        component = Em.Object.create({
-          selectedConfigGroup: {isDefault: true},
-          configGroups: Em.A([
-            Em.Object.create({name: 'n1', properties: []})
-          ])
-        });
-        installerStep7Controller._updateOverridesForConfig(serviceConfigProperty, component);
-      });
-
-      afterEach(function () {
-        App.get.restore();
-      });
-      it('there is 1 override', function () {
-        expect(serviceConfigProperty.get('overrides').length).to.equal(1);
-      });
-      it('override.value is valid', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.value')).to.equal('new value');
-      });
-      it('override is not original SCP', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.isOriginalSCP')).to.equal(false);
-      });
-      it('override.parentSCP is valid', function () {
-        expect(serviceConfigProperty.get('overrides.firstObject.parentSCP')).to.eql(serviceConfigProperty);
-      });
-      it('there is 1 property in the config group', function () {
-        expect(component.get('configGroups.firstObject.properties').length).to.equal(1);
-      });
-      it('property in the config group is not editable', function () {
-        expect(component.get('configGroups.firstObject.properties.firstObject.isEditable')).to.equal(false);
-      });
-      it('property in the config group is linked to it', function () {
-        expect(component.get('configGroups.firstObject.properties.firstObject.group')).to.be.object;
-      });
-    });
-
-  });
-
   describe('#setInstalledServiceConfigs', function () {
 
     var controller = App.WizardStep7Controller.create({
@@ -2427,7 +2342,7 @@ describe('App.InstallerStep7Controller', function () {
         configKeyToConfigMap: {
           type1: {},
           type2: {
-            p4: {}
+            p4: Em.Object.create({})
           }
         }
       };


Mime
View raw message