Repository: ambari
Updated Branches:
  refs/heads/branch-1.7.0 7df59aa3f -> 26503deb0


AMBARI-7813. Slider View. Add App Wizard. Back from 3rd to 2nd step issue. 
(onechiporenko)


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

Branch: refs/heads/branch-1.7.0
Commit: 26503deb0d993d71197009f2f416bf9d2bfcc794
Parents: 7df59aa
Author: Oleg Nechiporenko <onechipore...@apache.org>
Authored: Thu Oct 16 15:22:12 2014 +0300
Committer: Oleg Nechiporenko <onechipore...@apache.org>
Committed: Thu Oct 16 15:22:12 2014 +0300

----------------------------------------------------------------------
 .../createAppWizard/step2_controller.js         | 35 ++++++++++++--------
 .../processes/create_new_app_test.js            | 31 ++++++++++++++++-
 2 files changed, 51 insertions(+), 15 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/26503deb/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js
----------------------------------------------------------------------
diff --git 
a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js
 
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js
index 7adbf08..181e81d 100644
--- 
a/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js
+++ 
b/contrib/views/slider/src/main/resources/ui/app/controllers/createAppWizard/step2_controller.js
@@ -77,24 +77,31 @@ App.CreateAppWizardStep2Controller = 
Ember.ArrayController.extend({
 
   /**
    * Fill <code>content</code> with objects created from 
<code>App.SliderAppTypeComponent</code>
+   * If user come from 3 or 4 step, <code>newApp.components</code> are used
    * @method loadTypeComponents
    */
   loadTypeComponents: function () {
     var content = [],
-        component = this.get('typeComponent'),
-        allTypeComponents = this.get('newApp.appType.components');
-    if (allTypeComponents && allTypeComponents.get('length')) {
-      allTypeComponents.forEach(function (typeComponent) {
-        content.push(component.create({
-          displayName: typeComponent.get('displayName'),
-          name: typeComponent.get('name'),
-          priority: typeComponent.get('priority'),
-          numInstances: typeComponent.get('defaultNumInstances').toString(),
-          yarnMemory: typeComponent.get('defaultYARNMemory').toString(),
-          yarnCPU: typeComponent.get('defaultYARNCPU').toString()
-        }));
-      });
-      this.set('content', content);
+      component = this.get('typeComponent'),
+      allTypeComponents = this.get('newApp.appType.components'),
+      existingComponents = this.get('appWizardController.newApp.components'); 
// user may back to current step from 3 or 4
+    if (existingComponents && existingComponents.get('length')) {
+      this.set('content', existingComponents);
+    }
+    else {
+      if (allTypeComponents && allTypeComponents.get('length')) {
+        allTypeComponents.forEach(function (typeComponent) {
+          content.push(component.create({
+            displayName: typeComponent.get('displayName'),
+            name: typeComponent.get('name'),
+            priority: typeComponent.get('priority'),
+            numInstances: typeComponent.get('defaultNumInstances').toString(),
+            yarnMemory: typeComponent.get('defaultYARNMemory').toString(),
+            yarnCPU: typeComponent.get('defaultYARNCPU').toString()
+          }));
+        });
+        this.set('content', content);
+      }
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/26503deb/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 a26d22c..ddef342 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
@@ -75,7 +75,7 @@ var appTypes = {
 
 var selectors = {
     buttonNext: 'button.next-btn',
-    buttonBack: 'button.btn:eq(1)',
+    buttonBack: '.btn-area button.btn:eq(1)',
     step2: {
       content: '#step2 table tbody'
     },
@@ -96,6 +96,7 @@ var selectors = {
       HBASE_MASTER: 4,
       HBASE_REGIONSERVER: 5
     },
+    yarnLabel: 'SOME LABEL',
     categoriesCount: 6,
     newConfig: {
       name: 'new_property',
@@ -318,4 +319,32 @@ test('check step3', function () {
       });
     });
   });
+});
+
+test('check step3 back', function () {
+
+  visit('/createAppWizard/step1');
+  fillIn('#app-name-input', newApp.name);
+  click(selectors.buttonNext);
+
+  andThen(function () {
+    fillIn(selectors.step2.content + ' tr:eq(0) .numInstances', 
newApp.components.HBASE_MASTER);
+    find(selectors.step2.content + ' tr:eq(0) .checkbox-inline').click();
+    fillIn(selectors.step2.content + ' tr:eq(0) .yarnLabel', newApp.yarnLabel);
+    fillIn(selectors.step2.content + ' tr:eq(1) .numInstances', 
newApp.components.HBASE_REGIONSERVER);
+    click(selectors.buttonNext);
+
+    andThen(function () {
+      click(selectors.buttonBack);
+
+      andThen(function () {
+        equal(find(selectors.step2.content + ' tr:eq(0) .numInstances').val(), 
newApp.components.HBASE_MASTER, 'Components count restored');
+        equal(find(selectors.step2.content + ' tr:eq(0) 
.checkbox-inline').attr('checked'), 'checked', 'YARN label checkbox restored');
+        equal(find(selectors.step2.content + ' tr:eq(0) .yarnLabel').val(), 
newApp.yarnLabel, 'YARN label input restored');
+        equal(find(selectors.step2.content + ' tr:eq(0) 
.yarnLabel').attr('disabled'), null, 'YARN label input not disabled');
+        equal(find(selectors.step2.content + ' tr:eq(1) .numInstances').val(), 
newApp.components.HBASE_REGIONSERVER, 'Components count restored (2)');
+      });
+    });
+  });
+
 });
\ No newline at end of file

Reply via email to