ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [24/30] ambari git commit: AMBARI-18784 Some static attributes of config properties are lost after return to Customize Services step of Add Service Wizard. (ababiichuk)
Date Thu, 03 Nov 2016 15:26:25 GMT
AMBARI-18784 Some static attributes of config properties are lost after return to Customize
Services step of Add Service Wizard. (ababiichuk)


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

Branch: refs/heads/branch-feature-AMBARI-18634
Commit: 753b8d5a0fe4866cc3350fdcfdf9509a5a3fbf59
Parents: 41442ce
Author: ababiichuk <ababiichuk@hortonworks.com>
Authored: Thu Nov 3 15:11:57 2016 +0200
Committer: ababiichuk <ababiichuk@hortonworks.com>
Committed: Thu Nov 3 15:11:57 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            | 14 +++-
 .../app/controllers/wizard/step7_controller.js  | 16 ----
 ambari-web/app/utils/config.js                  | 21 -----
 ambari-web/test/controllers/wizard_test.js      | 88 ++++++++++++++++++--
 4 files changed, 94 insertions(+), 45 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/753b8d5a/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index f195238..89d439a 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -934,11 +934,19 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
       if (_content.serviceName === 'YARN') {
         _content.set('configs', App.config.textareaIntoFileConfigs(_content.get('configs'),
'capacity-scheduler.xml'));
       }
-      _content.get('configs').forEach(function (_configProperty) {
-        if (!Em.isNone(_configProperty.get('group'))) {
+      _content.get('configs').forEach(function (_configProperties) {
+        if (!Em.isNone(_configProperties.get('group'))) {
           return false;
         }
-        var configProperty = App.config.createMinifiedConfig(_configProperty);
+        var configProperty = App.config.createDefaultConfig(
+          _configProperties.get('name'),
+          _configProperties.get('filename'),
+          // need to invert boolean because this argument will be inverted in method body
+          !_configProperties.get('isUserProperty'),
+          _configProperties.getProperties('value', 'isRequired', 'errorMessage', 'warnMessage')
+        );
+        configProperty = App.config.mergeStaticProperties(configProperty, _configProperties,
[], ['name', 'filename', 'isUserProperty', 'value']);
+
         if (this.isExcludedConfig(configProperty)) {
           configProperty.value = '';
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/753b8d5a/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 0bb06d1..e466d4e 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -492,22 +492,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
   },
 
   /**
-   * If configs are saved in store returns stored configs merged with stack
-   * otherwise return stack configs
-   * @returns {Object[]}
-   */
-  getInitialConfigs: function(storedConfigs) {
-    if (storedConfigs && storedConfigs.length) {
-      var mergedConfigs = [];
-      storedConfigs.forEach(function (c) {
-        mergedConfigs.push($.extend({}, App.configsCollection.getConfigByName(c.name, c.filename),
c));
-      });
-      return mergedConfigs;
-    }
-    return App.configsCollection.getAll();
-  },
-
-  /**
    * Update hawq configuration depending on the state of the cluster
    * @param {Array} configs
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/753b8d5a/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index fb6a15e..b84b406 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -1248,27 +1248,6 @@ App.config = Em.Object.create({
   },
 
   /**
-   * creates config object with non static properties like
-   * 'value', 'isFinal', 'errorMessage' and
-   * 'id', 'name', 'filename',
-   * @param configProperty
-   * @returns {Object}
-   */
-  createMinifiedConfig: function (configProperty) {
-    if (configProperty instanceof Ember.Object) {
-      return configProperty.getProperties('name', 'filename', 'serviceName', 'value', 'isFinal',
'isRequiredByAgent');
-    }
-    return {
-      name: configProperty.name,
-      filename: configProperty.filename,
-      serviceName: configProperty.serviceName,
-      value: configProperty.value,
-      isFinal: configProperty.isFinal,
-      isRequiredByAgent: configProperty.isRequiredByAgent
-    }
-  },
-
-  /**
    * Update config property value based on its current value and list of zookeeper server
hosts.
    * Used to prevent sort order issues.
    * <code>siteConfigs</code> object formatted according server's persist format
e.g.

http://git-wip-us.apache.org/repos/asf/ambari/blob/753b8d5a/ambari-web/test/controllers/wizard_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard_test.js b/ambari-web/test/controllers/wizard_test.js
index a2bdfae..922cc90 100644
--- a/ambari-web/test/controllers/wizard_test.js
+++ b/ambari-web/test/controllers/wizard_test.js
@@ -1074,19 +1074,49 @@ describe('App.WizardController', function () {
           serviceName: 'KERBEROS',
           configs: [
             Em.Object.create({
+              id: 'id',
               name: 'admin_password',
               value: 'value',
+              defaultValue: 'defaultValue',
+              description: 'description',
               serviceName: 'serviceName',
+              domain: 'domain',
+              isVisible: true,
+              isNotDefaultValue: true,
               isFinal: true,
-              filename: 'krb5-conf.xml'
+              defaultIsFinal: true,
+              supportsFinal: true,
+              filename: 'krb5-conf.xml',
+              displayType: 'string',
+              isRequiredByAgent: true,
+              hasInitialValue: true,
+              isRequired: true,
+              group: {name: 'group'},
+              showLabel: true,
+              category: 'some_category'
             }),
 
             Em.Object.create({
+              id: 'id',
               name: 'admin_principal',
               value: 'value',
+              defaultValue: 'defaultValue',
+              description: 'description',
               serviceName: 'serviceName',
+              domain: 'domain',
+              isVisible: true,
+              isNotDefaultValue: true,
               isFinal: true,
-              filename: 'krb5-conf.xml'
+              defaultIsFinal: true,
+              supportsFinal: true,
+              filename: 'krb5-conf.xml',
+              displayType: 'string',
+              isRequiredByAgent: true,
+              hasInitialValue: true,
+              isRequired: true,
+              group: {name: 'group'},
+              showLabel: true,
+              category: 'some_category'
             })
           ]
         })
@@ -1100,18 +1130,48 @@ describe('App.WizardController', function () {
         serviceName: 'HDFS',
         configs: [
           Em.Object.create({
+            id: 'id',
             name: 'name',
             value: 'value',
+            defaultValue: 'defaultValue',
+            description: 'description',
             serviceName: 'serviceName',
+            domain: 'domain',
+            isVisible: true,
+            isNotDefaultValue: true,
             isFinal: true,
-            filename: 'hdfs-site'
+            defaultIsFinal: true,
+            supportsFinal: true,
+            filename: 'hdfs-site',
+            displayType: 'string',
+            isRequiredByAgent: true,
+            hasInitialValue: true,
+            isRequired: true,
+            isUserProperty: true,
+            showLabel: true,
+            category: 'some_category'
           }),
           Em.Object.create({
+            id: 'id',
             name: 'name2',
             value: 'value',
+            defaultValue: 'defaultValue',
+            description: 'description',
             serviceName: 'serviceName',
+            domain: 'domain',
+            isVisible: true,
+            isNotDefaultValue: true,
             isFinal: true,
-            filename: 'hdfs-site'
+            defaultIsFinal: true,
+            supportsFinal: true,
+            filename: 'hdfs-site',
+            displayType: 'string',
+            isRequiredByAgent: true,
+            hasInitialValue: true,
+            isRequired: false,
+            isUserProperty: false,
+            showLabel: true,
+            category: 'some_category'
           })
         ]
       }),
@@ -1119,17 +1179,23 @@ describe('App.WizardController', function () {
         serviceName: 'YARN',
         configs: [
           Em.Object.create({
+            id: 'id',
             name: 'name',
             value: 'value',
+            defaultValue: 'defaultValue',
+            description: 'description',
             serviceName: 'serviceName',
+            domain: 'domain',
+            isVisible: true,
             isFinal: true,
-            filename: 'filename',
             defaultIsFinal: true,
             supportsFinal: true,
+            filename: 'filename',
             displayType: 'string',
             isRequiredByAgent: true,
             hasInitialValue: true,
             isRequired: true,
+            isUserProperty: false,
             group: {name: 'group'},
             showLabel: true,
             category: 'some_category'
@@ -1142,6 +1208,7 @@ describe('App.WizardController', function () {
       c.saveServiceConfigProperties(stepController);
       var saved = c.get('content.serviceConfigProperties');
       expect(saved.length).to.equal(2);
+      expect(saved[0].category).to.equal('some_category');
     });
 
     it('should not save admin_principal or admin_password to the localStorage', function
() {
@@ -1149,6 +1216,17 @@ describe('App.WizardController', function () {
       var saved = c.get('content.serviceConfigProperties');
       expect(saved.everyProperty('value', '')).to.be.true;
     });
+
+    it('should save `isUserProperty` and `isRequired` attributes correctly', function() {
+      c.saveServiceConfigProperties(stepController);
+      var saved = c.get('content.serviceConfigProperties'),
+          nameProp = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name',
'name'),
+          name2Prop = saved.filterProperty('filename', 'hdfs-site.xml').findProperty('name',
'name2');
+      assert.isTrue(Em.get(nameProp, 'isRequired'), 'hdfs-site.xml:name isRequired validation');
+      assert.isTrue(Em.get(nameProp, 'isUserProperty'), 'hdfs-site.xml:name isUserProperty
validation');
+      assert.isFalse(Em.get(name2Prop, 'isRequired'), 'hdfs-site.xml:name2 isRequired validation');
+      assert.isFalse(Em.get(name2Prop, 'isUserProperty'), 'hdfs-site.xml:name2 isUserProperty
validation');
+    });
   });
 
   describe('#enableStep', function () {


Mime
View raw message