Repository: ambari
Updated Branches:
  refs/heads/branch-2.4 8bf1a0b0b -> 1fa50522d


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/1fa50522
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/1fa50522
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/1fa50522

Branch: refs/heads/branch-2.4
Commit: 1fa50522d9974ed4270cec6d3fc8b35aab876348
Parents: 8bf1a0b
Author: ababiichuk <[email protected]>
Authored: Thu Nov 3 15:04:36 2016 +0200
Committer: ababiichuk <[email protected]>
Committed: Thu Nov 3 15:04:36 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            | 14 ++-
 .../app/controllers/wizard/step7_controller.js  | 21 +----
 ambari-web/test/controllers/wizard_test.js      | 97 +++++++++++++++++++-
 3 files changed, 107 insertions(+), 25 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1fa50522/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js 
b/ambari-web/app/controllers/wizard.js
index 8b979cd..6672728 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -936,11 +936,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/1fa50522/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 006c61e..ddf6a3c 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -471,7 +471,10 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
     var self = this;
     App.config.setPreDefinedServiceConfigs(this.get('addMiscTabToPage'));
 
-    var configs = 
this.getInitialConfigs(this.get('content.serviceConfigProperties'));
+    var storedConfigs = this.get('content.serviceConfigProperties');
+    debugger
+
+    var configs = storedConfigs && storedConfigs.length ? storedConfigs : 
App.configsCollection.getAll();
 
     this.set('groupsToDelete', 
this.get('wizardController').getDBProperty('groupsToDelete') || []);
     if (this.get('wizardController.name') === 'addServiceController' && 
!this.get('content.serviceConfigProperties.length')) {
@@ -485,22 +488,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/1fa50522/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 c936199..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,
+            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,11 +1179,26 @@ 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'
           })
         ]
       })
@@ -1132,7 +1207,8 @@ describe('App.WizardController', function () {
     it('should save configs from default config group to 
content.serviceConfigProperties', function () {
       c.saveServiceConfigProperties(stepController);
       var saved = c.get('content.serviceConfigProperties');
-      expect(saved.length).to.equal(3);
+      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 () {
@@ -1140,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 () {

Reply via email to