ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From akovale...@apache.org
Subject git commit: AMBARI-7674. Slider View: disable Finish button after clicking. (akovalenko)
Date Tue, 07 Oct 2014 15:12:28 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 c5b465bfd -> 7caa2518d


AMBARI-7674. Slider View: disable Finish button after clicking. (akovalenko)


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

Branch: refs/heads/branch-1.7.0
Commit: 7caa2518dbb8757719477b4763ca4bcb4751b381
Parents: c5b465b
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Tue Oct 7 18:11:25 2014 +0300
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Tue Oct 7 18:11:45 2014 +0300

----------------------------------------------------------------------
 .../createAppWizard/step4_controller.js         | 18 +++++-
 .../ui/app/templates/createAppWizard/step4.hbs  |  5 +-
 .../createAppWizard/step4_controller_test.js    | 59 ++++++++++++++++++++
 3 files changed, 80 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7caa2518/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
index b128c8f..d19801b 100644
--- a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
+++ b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step4_controller.js
@@ -29,6 +29,12 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
   newApp: null,
 
   /**
+   * Define if submit button is disabled
+   * @type {Boolean}
+   */
+  isSubmitDisabled: false,
+
+  /**
    * Return formatted configs to show them on preview page
    * @return {String}
    */
@@ -128,13 +134,15 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
     if (app.queueName != null && app.queueName.trim().length > 0) {
       dataObj.queue = app.queueName.trim();
     }
+    this.set('isSubmitDisabled', true);
     return App.ajax.send({
       name: 'createNewApp',
       sender: this,
       data: {
         data: dataObj
       },
-      success: 'sendAppDataToServerSuccessCallback'
+      success: 'sendAppDataToServerSuccessCallback',
+      complete: 'sendAppDataToServerCompleteCallback'
     });
   },
 
@@ -146,6 +154,14 @@ App.CreateAppWizardStep4Controller = Ember.ObjectController.extend(App.AjaxError
     this.get('appWizardController').hidePopup();
   },
 
+  /**
+   * Complete-callback for "create new app"-request
+   * @method sendAppDataToServerCompleteCallback
+   */
+  sendAppDataToServerCompleteCallback: function () {
+    this.set('isSubmitDisabled', false);
+  },
+
   actions: {
 
     /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/7caa2518/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step4.hbs
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step4.hbs
b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step4.hbs
index 29a9062..9174f9c 100644
--- a/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step4.hbs
+++ b/contrib/views/slider/src/main/resources/ui/app/templates/createAppWizard/step4.hbs
@@ -32,6 +32,9 @@
 <pre>{{controller.configsFormatted}}</pre>
 
 <div class="btn-area">
-  <button class="btn btn-success pull-right" {{action finish target="controller"}}>{{t
common.finish}}</button>
+  <button
+      class="btn btn-success pull-right"
+    {{bind-attr disabled="controller.isSubmitDisabled"}}
+    {{action finish target="controller"}}>{{t common.finish}}</button>
 </div>
 </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/7caa2518/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step4_controller_test.js
----------------------------------------------------------------------
diff --git a/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step4_controller_test.js
b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step4_controller_test.js
new file mode 100644
index 0000000..72162b5
--- /dev/null
+++ b/contrib/views/slider/src/main/resources/ui/test/unit/controllers/createAppWizard/step4_controller_test.js
@@ -0,0 +1,59 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+moduleFor('controller:createAppWizardStep4', 'App.CreateAppWizardStep4Controller', {
+
+  needs: [
+    'controller:createAppWizard'
+  ],
+
+  setup: function () {
+    App.ajax.send = Em.K;
+  },
+
+  teardown: function () {
+    App.reset();
+  }
+
+});
+
+test('isSubmitDisabled', function () {
+
+  var controller = this.subject({
+    newApp: Em.Object.create({
+      appType: {
+        index: 'test',
+        version: 'test'
+      },
+      name: test,
+      configs: [],
+      components: [],
+      queue: 'test',
+      queueName: 'test'
+    })
+  });
+
+  equal(controller.get('isSubmitDisabled'), false, 'should be false by default');
+
+  controller.sendAppDataToServer();
+  equal(controller.get('isSubmitDisabled'), true, 'should be true after sendAppDataToServer
call');
+
+  controller.sendAppDataToServerCompleteCallback();
+  equal(controller.get('isSubmitDisabled'), false, 'should be false after sendAppDataToServerCompleteCallback
call');
+
+});


Mime
View raw message