Repository: ambari
Updated Branches:
  refs/heads/trunk d239381eb -> 69e112bae


AMBARI-11160. New required parameters for Hive and HBase on navigating back to 
Customize Services page after install failure (onechiporenko)


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

Branch: refs/heads/trunk
Commit: 69e112bae1bba1c06b7165616a7b59b4f9e22ae9
Parents: d239381
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Fri May 15 13:01:15 2015 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Fri May 15 13:01:15 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/wizard.js            |  1 +
 .../app/controllers/wizard/step7_controller.js  | 60 ++++++++++++++++----
 .../mixins/common/configs/enhanced_configs.js   |  9 ++-
 ambari-web/app/mixins/common/serverValidator.js |  3 -
 ambari-web/app/utils/config.js                  |  7 ++-
 ambari-web/package.json                         |  2 +-
 .../test/controllers/wizard/step7_test.js       | 43 ++++++++++++++
 .../test/controllers/wizard/step8_test.js       |  8 ++-
 8 files changed, 112 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js 
b/ambari-web/app/controllers/wizard.js
index 87027b9..22d3bbc 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -890,6 +890,7 @@ App.WizardController = 
Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
         var configProperty = {
           id: _configProperties.get('id'),
           name: _configProperties.get('name'),
+          displayName: _configProperties.get('displayName'),
           value: _configProperties.get('value'),
           defaultValue: _configProperties.get('defaultValue'),
           description: _configProperties.get('description'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/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 4a7c2df..bc716b5 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -265,10 +265,12 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
    * @method clearStep
    */
   clearStep: function () {
-    this.set('configValidationGlobalMessage', []);
-    this.set('submitButtonClicked', false);
-    this.set('isSubmitDisabled', true);
-    this.set('isRecommendedLoaded', false);
+    this.setProperties({
+      configValidationGlobalMessage: [],
+      submitButtonClicked: false,
+      isSubmitDisabled: true,
+      isRecommendedLoaded: false
+    });
     this.get('stepConfigs').clear();
     this.set('filter', '');
     this.get('filterColumns').setEach('selected', false);
@@ -582,6 +584,7 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
       }
     }
   },
+
   /**
    * On load function
    * @method loadStep
@@ -624,8 +627,8 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
     if (this.get('allSelectedServiceNames').contains('YARN')) {
       configs = App.config.fileConfigsIntoTextarea(configs, 
'capacity-scheduler.xml');
     }
-    var dependendServices = ["STORM", "YARN"];
-    dependendServices.forEach(function (serviceName) {
+    var dependedServices = ["STORM", "YARN"];
+    dependedServices.forEach(function (serviceName) {
       if (this.get('allSelectedServiceNames').contains(serviceName)) {
         this.resolveServiceDependencyConfigs(serviceName, configs);
       }
@@ -639,11 +642,22 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
         self.addKerberosDescriptorConfigs(configs, 
self.get('wizardController.kerberosDescriptorConfigs') || []);
       }
       self.setStepConfigs(configs, storedConfigs);
+
+      var serviceConfigProperties = 
(self.get('content.serviceConfigProperties') || []).mapProperty('name');
+      var recommendedToDelete = 
self.get('_dependentConfigValues').filterProperty('toDelete');
+      recommendedToDelete.forEach(function (c) {
+        var name = Em.get(c, 'propertyName');
+        if (serviceConfigProperties.contains(name)) {
+          
Em.set(self.get('_dependentConfigValues').findProperty('propertyName', name), 
'toDelete', false);
+        }
+      });
+
       self.updateDependentConfigs();
       self.clearDependentConfigs();
       self.checkHostOverrideInstaller();
       self.activateSpecialConfigs();
       self.selectProperService();
+      self.restoreRecommendedConfigs();
       if (self.get('content.skipConfigStep')) {
         App.router.send('next');
       }
@@ -651,6 +665,32 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
   },
 
   /**
+   * After user navigates back to step7, values for depended configs should be 
set to values set by user and not to default values
+   * @method restoreRecommendedConfigs
+   */
+  restoreRecommendedConfigs: function () {
+    var recommendationsConfigs = this.get('recommendationsConfigs') || {};
+    var serviceConfigProperties = this.get('content.serviceConfigProperties') 
|| [];
+    var stepConfigs = this.get('stepConfigs');
+    Em.keys(recommendationsConfigs).forEach(function (file) {
+      
(Em.keys(recommendationsConfigs[file].properties).concat(Em.keys(recommendationsConfigs[file].property_attributes
 || {}))).forEach(function (configName) {
+        stepConfigs.forEach(function (stepConfig) {
+          stepConfig.get('configs').filterProperty('name', 
configName).forEach(function (configProperty) {
+            if (Em.get(configProperty, 'filename').contains(file)) {
+              var scps = serviceConfigProperties.filterProperty('name', 
configName).filter(function (cp) {
+                return Em.get(cp, 'filename').contains(file);
+              });
+              if (scps.length) {
+                Em.set(configProperty, 'value', Em.get(scps[0], 'value'));
+              }
+            }
+          });
+        });
+      });
+    });
+  },
+
+  /**
    * Mark descriptor properties in configuration object.
    *
    * @param {Object[]} configs - config properties to change
@@ -1179,18 +1219,14 @@ App.WizardStep7Controller = 
Em.Controller.extend(App.ServerValidatorMixin, App.E
           // error popup before you can proceed
           return App.ModalPopup.show({
             header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'),
-            bodyClass: Ember.View.extend({
-              template: 
Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.body'))
-            }),
+            body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'),
             secondary: 
Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'),
             primary: 
Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'),
             onSecondary: function () {
               var parent = this;
               return App.ModalPopup.show({
                 header: 
Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'),
-                bodyClass: Ember.View.extend({
-                  template: 
Ember.Handlebars.compile(Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'))
-                }),
+                body: 
Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'),
                 onPrimary: function () {
                   this.hide();
                   parent.hide();

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/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 a30d0c9..853a1ab 100644
--- a/ambari-web/app/mixins/common/configs/enhanced_configs.js
+++ b/ambari-web/app/mixins/common/configs/enhanced_configs.js
@@ -114,8 +114,10 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    * @private
    */
   clearDependentConfigs: function() {
-    this.set('groupsToSave', {});
-    this.set('_dependentConfigValues', []);
+    this.setProperties({
+      groupsToSave: {},
+      _dependentConfigValues: []
+    });
   },
 
   onConfigGroupChangeForEnhanced: function() {
@@ -198,7 +200,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
 
   /**
    * sends request to get values for dependent configs
-   * @param {Object[]} changedConfigs - list of changed configs to track 
recommendations
+   * @param {{type: string, name: string}[]} changedConfigs - list of changed 
configs to track recommendations
    * @param {Boolean} initial
    * @param {Function} onComplete
    * @returns {$.ajax|null}
@@ -283,6 +285,7 @@ App.EnhancedConfigsMixin = Em.Mixin.create({
    */
   dependenciesSuccess: function (data, opt, params) {
     this._saveRecommendedValues(data, params.initial, 
params.dataToSend.changed_configurations);
+    this.set("recommendationsConfigs", Em.get(data.resources[0] , 
"recommendations.blueprint.configurations"));
     if (!params.initial) {
       this.updateDependentConfigs();
     }

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/ambari-web/app/mixins/common/serverValidator.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/serverValidator.js 
b/ambari-web/app/mixins/common/serverValidator.js
index 5b2057e..8854985 100644
--- a/ambari-web/app/mixins/common/serverValidator.js
+++ b/ambari-web/app/mixins/common/serverValidator.js
@@ -114,9 +114,6 @@ App.ServerValidatorMixin = Em.Mixin.create({
    * @returns {*}
    */
   loadServerSideConfigsRecommendations: function() {
-    if (this.get('recommendationsConfigs')) {
-      return $.Deferred().resolve();
-    }
     return App.ajax.send({
       'name': 'config.recommendations',
       'sender': this,

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index 5949d6e..63dd741 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -517,6 +517,8 @@ App.config = Em.Object.create({
           configData.value = stored.value;
           configData.defaultValue = stored.defaultValue;
           configData.overrides = stored.overrides;
+          configData.displayName = stored.displayName;
+          configData.name = stored.name;
           configData.filename = stored.filename;
           configData.description = stored.description;
           configData.isVisible = stored.isVisible;
@@ -561,6 +563,7 @@ App.config = Em.Object.create({
             configData.isFinal = storedCfg.isFinal;
             configData.supportsFinal = storedCfg.supportsFinal;
             configData.showLabel = !!storedCfg.showLabel;
+            configData.displayName = storedCfg.displayName;
           } else if (isAdvanced) {
             advanced = advancedConfigs.filterProperty('filename', 
configData.filename).findProperty('name', configData.name);
             this.setPropertyFromStack(configData, advanced);
@@ -574,7 +577,7 @@ App.config = Em.Object.create({
 
   /**
    *
-   * @param configData {Object} Configs that will be binded to the view on 
step-7 of installer wizard
+   * @param configData {Object} Configs that will be bound to the view on 
step-7 of installer wizard
    * @param advanced {Object} Config property loaded from Server side stack 
definition
    */
   setPropertyFromStack: function (configData, advanced) {
@@ -589,6 +592,8 @@ App.config = Em.Object.create({
     }
     configData.defaultValue = configData.value;
     configData.filename = advanced ? advanced.filename : configData.filename;
+    configData.displayName = advanced && advanced.displayName ? 
advanced.displayName : configData.displayName;
+    configData.name = advanced && advanced.name ? advanced.name : 
configData.name;
     configData.description = advanced ? advanced.description : 
configData.description;
     configData.isFinal = !!(advanced && (advanced.isFinal === "true"));
     configData.supportsFinal = !!(advanced && advanced.supportsFinal);

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/ambari-web/package.json
----------------------------------------------------------------------
diff --git a/ambari-web/package.json b/ambari-web/package.json
index 7bdaddc..d18b162 100644
--- a/ambari-web/package.json
+++ b/ambari-web/package.json
@@ -1,7 +1,7 @@
 {
   "name": "Ambari",
   "description": "Front-end package for the Apache Ambari Project",
-  "version": "1.7.0",
+  "version": "2.1.0",
   "homepage": "http://ambari.apache.org/";,
   "repository": {
     "type": "git",

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/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 2ea90cb..044ebbb 100644
--- a/ambari-web/test/controllers/wizard/step7_test.js
+++ b/ambari-web/test/controllers/wizard/step7_test.js
@@ -2003,4 +2003,47 @@ describe('App.InstallerStep7Controller', function () {
 
   });
 
+  describe('#restoreRecommendedConfigs', function () {
+
+    var recommendationsConfigs = {
+      site: {
+        properties: {
+          a: 'recommendedA',
+          b: 'recommendedB'
+        }
+      }
+    };
+    var stepConfigs = [
+      Em.Object.create({
+        serviceName: 'srv',
+        configs: [
+          {name: 'a', value: '--', filename: 'site'},
+          {name: 'b', value: '--', filename: 'Custom site'}
+        ]
+      })
+    ];
+    var serviceConfigProperties = [
+      {name: 'a', value: 'valueA', filename: 'site'},
+      {name: 'b', value: 'valueB', filename: 'Custom site'}
+    ];
+
+    beforeEach(function() {
+      installerStep7Controller.reopen({
+        content: {
+          serviceConfigProperties: serviceConfigProperties
+        },
+        recommendationsConfigs: recommendationsConfigs,
+        stepConfigs: stepConfigs
+      });
+    });
+
+    it('should restore provided by user values', function () {
+      installerStep7Controller.restoreRecommendedConfigs();
+      var configs = installerStep7Controller.get('stepConfigs')[0].configs;
+      expect(Em.get(configs.findProperty('name', 'a'), 
'value')).to.equal('valueA');
+      expect(Em.get(configs.findProperty('name', 'b'), 
'value')).to.equal('valueB');
+    });
+
+  });
+
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/69e112ba/ambari-web/test/controllers/wizard/step8_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step8_test.js 
b/ambari-web/test/controllers/wizard/step8_test.js
index 2dd939a..432f8e0 100644
--- a/ambari-web/test/controllers/wizard/step8_test.js
+++ b/ambari-web/test/controllers/wizard/step8_test.js
@@ -1713,7 +1713,13 @@ describe('App.WizardStep8Controller', function () {
 
   describe('#applyInstalledServicesConfigurationGroup', function() {
     beforeEach(function() {
-      sinon.stub($, 'ajax', Em.K);
+      sinon.stub($, 'ajax', function () {
+        return {
+          retry: function () {
+            return {then: Em.K}
+          }
+        }
+      });
       sinon.stub(App.router, 'get', function() {
         return configurationController;
       });

Reply via email to