ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From alexantone...@apache.org
Subject [1/3] ambari git commit: AMBARI-9629. General issues on Recommendations/Validations functionality (alexantonenko)
Date Fri, 13 Feb 2015 18:05:25 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 19ff44731 -> c337b6ea5


AMBARI-9629. General issues on Recommendations/Validations functionality (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 73416b6a7bd1feb04a8d113bd3cf7f5dff867cb6
Parents: 19ff447
Author: Alex Antonenko <hiveww@gmail.com>
Authored: Fri Feb 13 18:05:14 2015 +0200
Committer: Alex Antonenko <hiveww@gmail.com>
Committed: Fri Feb 13 20:03:01 2015 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step5_controller.js  | 31 ++++++++-----
 ambari-web/app/routes/add_service_routes.js     |  2 +
 ambari-web/app/routes/installer.js              |  6 ++-
 .../test/controllers/wizard/step5_test.js       | 47 ++++++++++++++++++++
 4 files changed, 73 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/73416b6a/ambari-web/app/controllers/wizard/step5_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step5_controller.js b/ambari-web/app/controllers/wizard/step5_controller.js
index 204eb26..5a63a1f 100644
--- a/ambari-web/app/controllers/wizard/step5_controller.js
+++ b/ambari-web/app/controllers/wizard/step5_controller.js
@@ -162,6 +162,12 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin,
{
   generalWarningMessages: [],
 
   /**
+   * Is masters-hosts layout initial one
+   * @type {bool}
+   */
+  isInitialLayout: true,
+
+  /**
    * true if any error exists
    */
   anyError: function() {
@@ -243,32 +249,33 @@ App.WizardStep5Controller = Em.Controller.extend(App.BlueprintMixin,
{
    * @metohd updateIsSubmitDisabled
    */
   updateIsSubmitDisabled: function () {
-    var self = this;
 
-    if (self.thereIsNoMasters()) {
+    if (this.thereIsNoMasters()) {
       return false;
     }
 
-    if (this.get('useServerValidation')) {
-      self.set('submitDisabled', true);
+    var isSubmitDisabled = this.get('servicesMasters').someProperty('isHostNameValid', false);
 
-      // reset previous recommendations
-      this.clearRecommendations();
+    if (this.get('useServerValidation')) {
+      this.set('submitDisabled', true);
 
-      if (self.get('servicesMasters').length === 0) {
+      if (this.get('servicesMasters').length === 0) {
         return;
       }
 
-      var isSubmitDisabled = this.get('servicesMasters').someProperty('isHostNameValid',
false);
       if (!isSubmitDisabled) {
-        self.recommendAndValidate();
+        if (!this.get('isInitialLayout')) {
+          this.clearRecommendations(); // reset previous recommendations
+        } else {
+          this.set('isInitialLayout', false);
+        }
+        this.recommendAndValidate();
       }
     } else {
-      var isSubmitDisabled = this.get('servicesMasters').someProperty('isHostNameValid',
false);
-      self.set('submitDisabled', isSubmitDisabled);
+      this.set('submitDisabled', isSubmitDisabled);
       return isSubmitDisabled;
     }
-  }.observes('servicesMasters.@each.selectedHost', 'servicesMasters.@each.isHostNameValid'),
+  }.observes('servicesMasters.@each.selectedHost'),
 
   /**
    * Send AJAX request to validate current host layout

http://git-wip-us.apache.org/repos/asf/ambari/blob/73416b6a/ambari-web/app/routes/add_service_routes.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js
index 3d3b1ea..44051ba 100644
--- a/ambari-web/app/routes/add_service_routes.js
+++ b/ambari-web/app/routes/add_service_routes.js
@@ -128,8 +128,10 @@ module.exports = App.WizardRoute.extend({
     connectOutlets: function (router) {
       console.log('in addService.step2:connectOutlets');
       var controller = router.get('addServiceController');
+      var wizardStep2Controller = router.get('wizardStep5Controller');
       controller.setCurrentStep('2');
       controller.set('hideBackButton', false);
+      wizardStep2Controller.set('isInitialLayout', true);
       controller.dataLoading().done(function () {
         controller.loadAllPriorSteps().done(function () {
           controller.connectOutlet('wizardStep5', controller.get('content'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/73416b6a/ambari-web/app/routes/installer.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/installer.js b/ambari-web/app/routes/installer.js
index fef2e4a..57fe93a 100644
--- a/ambari-web/app/routes/installer.js
+++ b/ambari-web/app/routes/installer.js
@@ -263,7 +263,11 @@ module.exports = Em.Route.extend({
       router.setNavigationFlow('step5');
 
       var controller = router.get('installerController');
-      router.get('wizardStep5Controller').set('servicesMasters', []);
+      var wizardStep5Controller = router.get('wizardStep5Controller');
+      wizardStep5Controller.setProperties({
+        servicesMasters: [],
+        isInitialLayout: true
+      });
       controller.setCurrentStep('5');
       controller.loadAllPriorSteps().done(function () {
         controller.connectOutlet('wizardStep5', controller.get('content'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/73416b6a/ambari-web/test/controllers/wizard/step5_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/wizard/step5_test.js b/ambari-web/test/controllers/wizard/step5_test.js
index df592e0..f4dc6fc 100644
--- a/ambari-web/test/controllers/wizard/step5_test.js
+++ b/ambari-web/test/controllers/wizard/step5_test.js
@@ -843,10 +843,44 @@ describe('App.WizardStep5Controller', function () {
 
   describe('#updateIsSubmitDisabled', function () {
 
+    var clearCases = [
+      {
+        isHostNameValid: true,
+        isInitialLayout: true,
+        isInitialLayoutResulting: false,
+        clearRecommendationsCallCount: 0,
+        recommendAndValidateCallCount: 1,
+        title: 'initial masters-hosts layout'
+      },
+      {
+        isHostNameValid: true,
+        isInitialLayout: false,
+        isInitialLayoutResulting: false,
+        clearRecommendationsCallCount: 1,
+        recommendAndValidateCallCount: 1,
+        title: 'master-hosts layout changed'
+      },
+      {
+        isHostNameValid: false,
+        isInitialLayout: false,
+        isInitialLayoutResulting: false,
+        clearRecommendationsCallCount: 0,
+        recommendAndValidateCallCount: 0,
+        title: 'invalid host name specified'
+      }
+    ];
+
     beforeEach(function () {
       c.set('selectedServicesMasters', [
         {isInstalled: false}
       ]);
+      sinon.stub(c, 'clearRecommendations', Em.K);
+      sinon.stub(c, 'recommendAndValidate', Em.K);
+    });
+
+    afterEach(function () {
+      c.clearRecommendations.restore();
+      c.recommendAndValidate.restore();
     });
 
     it('shouldn\'t change submitDisabled if thereIsNoMasters returns false', function ()
{
@@ -879,6 +913,19 @@ describe('App.WizardStep5Controller', function () {
 
     });
 
+    clearCases.forEach(function (item) {
+      it(item.title, function () {
+        c.setProperties({
+          isInitialLayout: item.isInitialLayout,
+          servicesMasters: [{
+            isHostNameValid: item.isHostNameValid
+          }]
+        });
+        expect(c.get('isInitialLayout')).to.equal(item.isInitialLayoutResulting);
+        expect(c.clearRecommendations.callCount).to.equal(item.clearRecommendationsCallCount);
+        expect(c.recommendAndValidate.callCount).to.equal(item.recommendAndValidateCallCount);
+      });
+    });
 
   });
 


Mime
View raw message