ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From onechipore...@apache.org
Subject git commit: AMBARI-7987. User may skip steps on Slider Wizard. (onechiporenko)
Date Mon, 27 Oct 2014 15:54:50 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 838ca1780 -> 412666fd8


AMBARI-7987. User may skip steps on Slider Wizard. (onechiporenko)


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

Branch: refs/heads/branch-1.7.0
Commit: 412666fd87eb704f9de0f15ce1249712a3bbb836
Parents: 838ca17
Author: Oleg Nechiporenko <onechiporenko@apache.org>
Authored: Mon Oct 27 17:25:09 2014 +0200
Committer: Oleg Nechiporenko <onechiporenko@apache.org>
Committed: Mon Oct 27 17:25:09 2014 +0200

----------------------------------------------------------------------
 .../createAppWizard/step1_controller.js         | 36 +++++++++++----
 .../processes/create_new_app_test.js            |  1 +
 .../createAppWizard/step1_controller_test.js    | 46 +++++++++++++++-----
 3 files changed, 62 insertions(+), 21 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/412666fd/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
index 0a59916..5d3ade7 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step1_controller.js
@@ -53,10 +53,19 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
   nameErrorMessage: '',
 
   /**
+   * Determines if request for validating new App name is sent
+   * If true - "Next" button should be disabled
+   * Set to false after request is finished
+   * @type {bool}
+   */
+  validateAppNameRequestExecuting: false,
+
+  /**
    * Define if there are existing App types
    * @type {Boolean}
    */
   isAppTypesError: Em.computed.equal('availableTypes.content.length', 0),
+
   /**
    * Define description depending on selected App type
    * @type {string}
@@ -72,8 +81,8 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
    * @type {bool}
    */
   isSubmitDisabled: function () {
-    return !this.get('newApp.name') || this.get('isNameError') || this.get('isAppTypesError');
-  }.property('newApp.name', 'isNameError', 'isAppTypesError'),
+    return this.get('validateAppNameRequestExecuting') || !this.get('newApp.name') || this.get('isNameError')
|| this.get('isAppTypesError');
+  }.property('newApp.name', 'isNameError', 'isAppTypesError', 'validateAppNameRequestExecuting'),
 
   /**
    * Initialize new App and set it to <code>newApp</code>
@@ -149,26 +158,25 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
 
   /**
    * Proceed if app name has failed server validation
-   * @method {validateAppNameSuccessCallback}
+   * @method {validateAppNameErrorCallback}
    */
   validateAppNameErrorCallback: function (request, ajaxOptions, error, opt, params) {
     if (request.status == 409) {
-      var self = this;
       Bootstrap.ModalManager.open(
         'app-name-conflict',
         Em.I18n.t('common.error'),
         Em.View.extend({
-          template: Em.Handlebars.compile('<div class="alert alert-danger">' +
-            Em.I18n.t('wizard.step1.validateAppNameError').format(params.name) + '</div>')
+          classNames: ['alert', 'alert-danger'],
+          template: Em.Handlebars.compile(Em.I18n.t('wizard.step1.validateAppNameError').format(params.name))
         }),
         [
-          Ember.Object.create({
+          Em.Object.create({
             title: Em.I18n.t('ok'),
             dismiss: 'modal',
             type: 'success'
           })
         ],
-        self
+        this
       );
     } else {
       this.defaultErrorHandler(request, opt.url, opt.type, true);
@@ -176,6 +184,14 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
   },
 
   /**
+   * Complete-callback for validating newAppName request
+   * @method validateAppNameCompleteCallback
+   */
+  validateAppNameCompleteCallback: function() {
+    this.set('validateAppNameRequestExecuting', false);
+  },
+
+  /**
    * Save new application data to wizard controller
    * @method saveApp
    */
@@ -189,6 +205,7 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
 
   actions: {
     submit: function () {
+      this.set('validateAppNameRequestExecuting', true);
       return App.ajax.send({
         name: 'validateAppName',
         sender: this,
@@ -196,7 +213,8 @@ App.CreateAppWizardStep1Controller = Ember.Controller.extend(App.AjaxErrorHandle
           name: this.get('newApp.name')
         },
         success: 'validateAppNameSuccessCallback',
-        error: 'validateAppNameErrorCallback'
+        error: 'validateAppNameErrorCallback',
+        complete: 'validateAppNameCompleteCallback'
       });
     }
   }

http://git-wip-us.apache.org/repos/asf/ambari/blob/412666fd/contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js
b/contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js
index ac984b8..347d2fc 100644
--- a/contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/integration/processes/create_new_app_test.js
@@ -141,6 +141,7 @@ test('basic (no errors - just valid data)', function () {
     equal(find(selectors.buttonNext).attr('disabled'), null, '"Next"-button should be enabled
after user input a valid name');
   });
   click(selectors.buttonNext);
+  equal(find(selectors.buttonNext).attr('disabled'), 'disabled', '"Next"-button should be
disabled after click on it');
 
   andThen(function () {
     /* STEP 2 */

http://git-wip-us.apache.org/repos/asf/ambari/blob/412666fd/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
index aea7585..419a9ab 100644
--- a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step1_controller_test.js
@@ -38,7 +38,7 @@ test('isAppTypesError', function () {
 
 });
 
-test('nameValidator', function() {
+test('nameValidator', function () {
   expect(7);
 
   var tests = [
@@ -51,7 +51,7 @@ test('nameValidator', function() {
 
   var controller = this.subject({isNameError: false,
     store: Em.Object.create({
-      all: function(key) {
+      all: function (key) {
         return {
           sliderApp: [
             { name: 'slider2' }
@@ -61,17 +61,17 @@ test('nameValidator', function() {
     })
   });
 
-  tests.forEach(function(test) {
-    Em.run(function() {
+  tests.forEach(function (test) {
+    Em.run(function () {
       controller.set('newApp', { name: test.name});
     });
 
     equal(controller.get('isNameError'), test.e, 'Name `' + test.name + '` is' + (!!test.e
? ' not ' : ' ') + 'valid');
   });
 
-  Em.run(function() {
+  Em.run(function () {
     controller.set('newApp', { name: 'slider2'});
-  })
+  });
 
   equal(controller.get('isNameError'), true, 'Name `slider2` already exist');
   equal(controller.get('nameErrorMessage'), Em.I18n.t('wizard.step1.nameRepeatError'), 'Error
message should be shown');
@@ -85,12 +85,11 @@ test('validateAppNameSuccessCallback', function () {
         n0: 'v0'
       }
     }),
-    title = 'newApp should have {0} set';
-
-  var controller = this.subject({
-    newApp: Em.Object.create(),
-    selectedType: selectedType
-  });
+    title = 'newApp should have {0} set',
+    controller = this.subject({
+      newApp: Em.Object.create(),
+      selectedType: selectedType
+    });
 
   Em.run(function () {
     controller.set('appWizardController.transitionToRoute', Em.K);
@@ -103,4 +102,27 @@ test('validateAppNameSuccessCallback', function () {
   deepEqual(controller.get('appWizardController.newApp'), controller.get('newApp'), 'newApp
should be set in CreateAppWizardController');
   equal(controller.get('appWizardController.currentStep'), 2, 'should proceed to the next
step');
 
+});
+
+test('isSubmitDisabled', function () {
+
+  var controller = this.subject({
+    availableTypes: {
+      content: [
+        {}
+      ]
+    },
+    isNameError: false,
+    newApp: {
+      name: 'some'
+    }
+  });
+
+  equal(controller.get('isSubmitDisabled'), false);
+  Em.run(function () {
+    controller.set('validateAppNameRequestExecuting', true);
+  });
+
+  equal(controller.get('isSubmitDisabled'), true, 'button disabled when request executing');
+
 });
\ No newline at end of file


Mime
View raw message