Parcourir la source

AMBARI-12185. User is able to go back from deploy step of installer (onechiporenko)

Oleg Nechiporenko il y a 10 ans
Parent
commit
a51accc1c5

+ 18 - 10
ambari-web/app/controllers/wizard.js

@@ -47,18 +47,26 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM
   ],
 
   init: function () {
-    this.set('isStepDisabled', []);
     this.clusters = App.Cluster.find();
-    this.get('isStepDisabled').pushObject(Ember.Object.create({
-      step: 1,
-      value: false
-    }));
-    for (var i = 2; i <= this.get('totalSteps'); i++) {
-      this.get('isStepDisabled').pushObject(Ember.Object.create({
-        step: i,
-        value: true
+    this.setIsStepDisabled();
+  },
+
+  /**
+   * Set <code>isStepDisabled</code> with list of available steps (basing on <code>totalSteps</code>)
+   * @method setIsStepDisabled
+   */
+  setIsStepDisabled: function () {
+      this.set('isStepDisabled', []);
+      this.get('isStepDisabled').pushObject(Em.Object.create({
+        step: 1,
+        value: false
       }));
-    }
+      for (var i = 2; i <= this.get('totalSteps'); i++) {
+        this.get('isStepDisabled').pushObject(Em.Object.create({
+          step: i,
+          value: true
+        }));
+      }
   },
 
   slaveComponents: function () {

+ 2 - 0
ambari-web/app/mixins/routers/redirections.js

@@ -62,12 +62,14 @@ App.RouterRedirections = Em.Mixin.create({
       case 'SERVICE_STARTING_3' :
         if (!installerController.get('isStep9')) {
           installerController.setCurrentStep('9');
+          installerController.setLowerStepsDisable(9);
         }
         router.transitionTo(path + 'step' + installerController.get('currentStep'));
         break;
       case 'CLUSTER_INSTALLED_4' :
         if (!installerController.get('isStep10')) {
           installerController.setCurrentStep('10');
+          installerController.setLowerStepsDisable(10);
         }
         App.db.data = currentClusterStatus.localdb;
         App.get('router').setAuthenticated(true);

+ 9 - 2
ambari-web/test/mixins/routers/redirections_test.js

@@ -18,18 +18,25 @@
 
 var App = require('app');
 
-var route, installerController, currentClusterStatus;
+var router, installerController, currentClusterStatus;
 
-describe('App.Redirections', function () {
+describe('App.RouterRedirections', function () {
 
   beforeEach(function () {
 
     installerController = Em.Object.create({
       currentStep: '',
+      totalSteps: 11,
       setCurrentStep: function (k) {
         this.set('currentStep', k);
       }
     });
+    App.router.get('installerController').setIsStepDisabled.call(installerController);
+    installerController.setLowerStepsDisable = App.router.get('installerController').setLowerStepsDisable.bind(installerController);
+    installerController.get('isStepDisabled').pushObject(Ember.Object.create({
+      step: 0,
+      value: true
+    }));
 
     router = Em.Object.create(App.RouterRedirections, {
       transitionTo: Em.K,