Selaa lähdekoodia

AMBARI-8440. Create mixins for wizard views (onechiporenko)

Oleg Nechiporenko 10 vuotta sitten
vanhempi
commit
b4dd68dacf
27 muutettua tiedostoa jossa 229 lisäystä ja 467 poistoa
  1. 2 1
      ambari-web/app/assets/test/tests.js
  2. 1 0
      ambari-web/app/mixins.js
  3. 72 0
      ambari-web/app/mixins/wizard/wizard_menu_view.js
  4. 24 0
      ambari-web/app/router.js
  5. 1 7
      ambari-web/app/routes/add_alert_definition_routes.js
  6. 1 15
      ambari-web/app/routes/add_host_routes.js
  7. 1 14
      ambari-web/app/routes/add_kerberos_routes.js
  8. 1 9
      ambari-web/app/routes/add_security.js
  9. 0 14
      ambari-web/app/routes/add_service_routes.js
  10. 1 18
      ambari-web/app/routes/high_availability_routes.js
  11. 0 13
      ambari-web/app/routes/reassign_master_routes.js
  12. 1 8
      ambari-web/app/routes/rm_high_availability_routes.js
  13. 1 7
      ambari-web/app/routes/rollbackHA_routes.js
  14. 1 7
      ambari-web/app/routes/stack_upgrade.js
  15. 2 46
      ambari-web/app/views/installer.js
  16. 3 19
      ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js
  17. 3 42
      ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js
  18. 1 21
      ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js
  19. 1 17
      ambari-web/app/views/main/admin/kerberos/wizard_view.js
  20. 2 18
      ambari-web/app/views/main/admin/security/add/menu.js
  21. 2 16
      ambari-web/app/views/main/admin/stack_upgrade.js
  22. 2 18
      ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js
  23. 1 33
      ambari-web/app/views/main/host/add_view.js
  24. 1 33
      ambari-web/app/views/main/service/add_view.js
  25. 1 29
      ambari-web/app/views/main/service/reassign_view.js
  26. 103 0
      ambari-web/test/mixins/wizard/wizard_menu_view_test.js
  27. 0 62
      ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js

+ 2 - 1
ambari-web/app/assets/test/tests.js

@@ -126,6 +126,7 @@ var files = ['test/init_model_test',
   'test/mixins/common/localStorage_test',
   'test/mixins/common/table_server_view_mixin_test',
   'test/mixins/main/host/details/host_components/decommissionable_test',
+  'test/mixins/wizard/wizard_menu_view_test',
   'test/utils/ajax/ajax_test',
   'test/utils/ajax/ajax_queue_test',
   'test/utils/batch_scheduled_requests_test',
@@ -156,7 +157,7 @@ var files = ['test/init_model_test',
   'test/views/common/configs/config_history_flow_test',
   'test/views/main/dashboard_test',
   'test/views/main/menu_test',
-  '/test/views/main/admin/stack_version/stack_version_details_test',
+  'test/views/main/admin/stack_version/stack_version_details_test',
   'test/views/main/dashboard/config_history_view_test',
   'test/views/main/dashboard/widget_test',
   'test/views/main/dashboard/widgets_test',

+ 1 - 0
ambari-web/app/mixins.js

@@ -32,3 +32,4 @@ require('mixins/wizard/wizardProgressPageView');
 require('mixins/wizard/wizardDeployProgressView');
 require('mixins/wizard/selectHost');
 require('mixins/wizard/addSecurityConfigs');
+require('mixins/wizard/wizard_menu_view');

+ 72 - 0
ambari-web/app/mixins/wizard/wizard_menu_view.js

@@ -0,0 +1,72 @@
+/**
+ * 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.
+ */
+
+
+var App = require('app');
+
+App.WizardMenuMixin = Em.Mixin.create({
+
+  isStepDisabled: function (index) {
+    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
+  },
+
+  isStep0Disabled: function () {
+    return this.isStepDisabled(0);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep1Disabled: function () {
+    return this.isStepDisabled(1);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep2Disabled: function () {
+    return this.isStepDisabled(2);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep3Disabled: function () {
+    return this.isStepDisabled(3);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep4Disabled: function () {
+    return this.isStepDisabled(4);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep5Disabled: function () {
+    return this.isStepDisabled(5);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep6Disabled: function () {
+    return this.isStepDisabled(6);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep7Disabled: function () {
+    return this.isStepDisabled(7);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep8Disabled: function () {
+    return this.isStepDisabled(8);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep9Disabled: function () {
+    return this.isStepDisabled(9);
+  }.property('controller.isStepDisabled.@each.value').cacheable(),
+
+  isStep10Disabled: function () {
+    return this.isStepDisabled(10);
+  }.property('controller.isStepDisabled.@each.value').cacheable()
+
+});

+ 24 - 0
ambari-web/app/router.js

@@ -19,9 +19,33 @@
 var App = require('app');
 
 App.WizardRoute = Em.Route.extend({
+
+  gotoStep0: Em.Router.transitionTo('step0'),
+
+  gotoStep1: Em.Router.transitionTo('step1'),
+
+  gotoStep2: Em.Router.transitionTo('step2'),
+
+  gotoStep3: Em.Router.transitionTo('step3'),
+
+  gotoStep4: Em.Router.transitionTo('step4'),
+
+  gotoStep5: Em.Router.transitionTo('step5'),
+
+  gotoStep6: Em.Router.transitionTo('step6'),
+
+  gotoStep7: Em.Router.transitionTo('step7'),
+
+  gotoStep8: Em.Router.transitionTo('step8'),
+
+  gotoStep9: Em.Router.transitionTo('step9'),
+
+  gotoStep10: Em.Router.transitionTo('step10'),
+
   isRoutable: function() {
     return (typeof this.get('route') === 'string' && App.router.get('loggedIn'));
   }.property('App.router.loggedIn')
+
 });
 
 App.Router = Em.Router.extend({

+ 1 - 7
ambari-web/app/routes/add_alert_definition_routes.js

@@ -130,12 +130,6 @@ module.exports = App.WizardRoute.extend({
           }
         });
     }
-  }),
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3')
+  })
 
 });

+ 1 - 15
ambari-web/app/routes/add_host_routes.js

@@ -349,21 +349,7 @@ module.exports = App.WizardRoute.extend({
   backToHostsList: function (router, event) {
     App.router.get('updateController').set('isWorking', true);
     router.transitionTo('hosts.index');
-  },
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4'),
-
-  gotoStep5: Em.Router.transitionTo('step5'),
-
-  gotoStep6: Em.Router.transitionTo('step6'),
-
-  gotoStep7: Em.Router.transitionTo('step7')
+  }
 
 
 });

+ 1 - 14
ambari-web/app/routes/add_kerberos_routes.js

@@ -237,19 +237,6 @@ module.exports = App.WizardRoute.extend({
       }});
 
     }
-  }),
-
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4'),
-
-  gotoStep5: Em.Router.transitionTo('step5'),
-
-  gotoStep6: Em.Router.transitionTo('step6')
+  })
 
 });

+ 1 - 9
ambari-web/app/routes/add_security.js

@@ -236,15 +236,7 @@ module.exports = App.WizardRoute.extend({
         $(context.currentTarget).parents("#modal").find(".close").trigger('click');
       }
     }
-  }),
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4')
+  })
 
 });
 

+ 0 - 14
ambari-web/app/routes/add_service_routes.js

@@ -330,20 +330,6 @@ module.exports = App.WizardRoute.extend({
     }
   }),
 
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4'),
-
-  gotoStep5: Em.Router.transitionTo('step5'),
-
-  gotoStep6: Em.Router.transitionTo('step6'),
-
-  gotoStep7: Em.Router.transitionTo('step7'),
-
   backToServices: function (router) {
     App.router.get('updateController').set('isWorking', true);
     router.transitionTo('services');

+ 1 - 18
ambari-web/app/routes/high_availability_routes.js

@@ -308,23 +308,6 @@ module.exports = App.WizardRoute.extend({
         localdb: App.db.data
       },{alwaysCallback: function() {controller.get('popup').hide();router.transitionTo('main.services.index');location.reload();}});
     }
-  }),
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4'),
-
-  gotoStep5: Em.Router.transitionTo('step5'),
-
-  gotoStep6: Em.Router.transitionTo('step6'),
-
-  gotoStep7: Em.Router.transitionTo('step7'),
-
-  gotoStep8: Em.Router.transitionTo('step8'),
+  })
 
-  gotoStep9: Em.Router.transitionTo('step9')
 });

+ 0 - 13
ambari-web/app/routes/reassign_master_routes.js

@@ -299,19 +299,6 @@ module.exports = App.WizardRoute.extend({
     }
   }),
 
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
-
-  gotoStep4: Em.Router.transitionTo('step4'),
-
-  gotoStep5: Em.Router.transitionTo('step5'),
-
-  gotoStep6: Em.Router.transitionTo('step6'),
-
   backToServices: function (router) {
     App.router.get('updateController').set('isWorking', true);
     router.transitionTo('services');

+ 1 - 8
ambari-web/app/routes/rm_high_availability_routes.js

@@ -196,13 +196,6 @@ module.exports = App.WizardRoute.extend({
         location.reload();
       }});
     }
-  }),
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3'),
+  })
 
-  gotoStep4: Em.Router.transitionTo('step4')
 });

+ 1 - 7
ambari-web/app/routes/rollbackHA_routes.js

@@ -150,12 +150,6 @@ module.exports = App.WizardRoute.extend({
       router.transitionTo('main.index');
       location.reload();
     }
-  }),
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3')
+  })
 
 });

+ 1 - 7
ambari-web/app/routes/stack_upgrade.js

@@ -118,12 +118,6 @@ module.exports = App.WizardRoute.extend({
     var controller = router.get('stackUpgradeController');
     controller.finish();
     $(context.currentTarget).parents("#modal").find(".close").trigger('click');
-  },
-
-  gotoStep1: Em.Router.transitionTo('step1'),
-
-  gotoStep2: Em.Router.transitionTo('step2'),
-
-  gotoStep3: Em.Router.transitionTo('step3')
+  }
 
 });

+ 2 - 46
ambari-web/app/views/installer.js

@@ -19,52 +19,8 @@
 
 var App = require('app');
 
-App.InstallerView = Em.View.extend({
+App.InstallerView = Em.View.extend(App.WizardMenuMixin, {
 
-  templateName: require('templates/installer'),
-
-  isStep0Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',0).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep1Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',1).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',2).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',3).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',4).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',5).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',6).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',7).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep8Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',8).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep9Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',9).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep10Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',10).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable()
+  templateName: require('templates/installer')
 
 });

+ 3 - 19
ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js

@@ -19,31 +19,15 @@
 
 var App = require('app');
 
-App.RollbackHighAvailabilityWizardView = Em.View.extend({
+App.RollbackHighAvailabilityWizardView = Em.View.extend(App.WizardMenuMixin, {
+
+  templateName: require('templates/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard'),
 
   didInsertElement: function() {
     var currentStep = this.get('controller.currentStep');
     if (currentStep > 4) {
       this.get('controller').setLowerStepsDisable(currentStep);
     }
-  },
-
-  templateName: require('templates/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard'),
-
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
   }
 
 });

+ 3 - 42
ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js

@@ -19,7 +19,8 @@
 
 var App = require('app');
 
-App.HighAvailabilityWizardView = Em.View.extend({
+App.HighAvailabilityWizardView = Em.View.extend(App.WizardMenuMixin, {
+
   templateName: require('templates/main/admin/highAvailability/nameNode/wizard'),
 
   isLoaded: false,
@@ -69,7 +70,7 @@ App.HighAvailabilityWizardView = Em.View.extend({
   /**
    * error callback of <code>loadHosts</code>
    */
-  loadHostsErrorCallback: function(){
+  loadHostsErrorCallback: function() {
     this.set('isLoaded', true);
   },
 
@@ -78,46 +79,6 @@ App.HighAvailabilityWizardView = Em.View.extend({
     if (currentStep > 4) {
       this.get('controller').setLowerStepsDisable(currentStep);
     }
-  },
-
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.isStepDisabled(7);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep8Disabled: function () {
-    return this.isStepDisabled(8);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep9Disabled: function () {
-    return this.isStepDisabled(9);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
   }
 
 });

+ 1 - 21
ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js

@@ -19,7 +19,7 @@
 
 var App = require('app');
 
-App.RMHighAvailabilityWizardView = Em.View.extend({
+App.RMHighAvailabilityWizardView = Em.View.extend(App.WizardMenuMixin, {
 
   didInsertElement: function() {
     var currentStep = this.get('controller.currentStep');
@@ -30,26 +30,6 @@ App.RMHighAvailabilityWizardView = Em.View.extend({
 
   templateName: require('templates/main/admin/highAvailability/resourceManager/wizard'),
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  },
-
   isLoaded: false,
 
   willInsertElement: function() {

+ 1 - 17
ambari-web/app/views/main/admin/kerberos/wizard_view.js

@@ -18,26 +18,10 @@
 
 var App = require('app');
 
-App.KerberosWizardView = Em.View.extend({
+App.KerberosWizardView = Em.View.extend(App.WizardMenuMixin, {
 
   templateName: require('templates/main/admin/kerberos/wizard'),
 
-  isStep1Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',1).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',2).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',3).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',4).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
   isStep5Disabled: true,
 
   isStep6Disabled: true,

+ 2 - 18
ambari-web/app/views/main/admin/security/add/menu.js

@@ -18,25 +18,9 @@
 
 var App = require('app');
 
-App.MainAdminSecurityAddMenuView = Em.View.extend({
+App.MainAdminSecurityAddMenuView = Em.View.extend(App.WizardMenuMixin, {
 
-  templateName: require('templates/main/admin/security/add/menu'),
-
-  isStep1Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',1).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',2).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',3).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.get('controller.isStepDisabled').findProperty('step',4).get('value');
-  }.property('controller.isStepDisabled.@each.value').cacheable()
+  templateName: require('templates/main/admin/security/add/menu')
 
 });
 

+ 2 - 16
ambari-web/app/views/main/admin/stack_upgrade.js

@@ -19,22 +19,8 @@
 
 var App = require('app');
 
-App.StackUpgradeView = Em.View.extend({
-  templateName: require('templates/main/admin/stack_upgrade'),
+App.StackUpgradeView = Em.View.extend(App.WizardMenuMixin, {
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
+  templateName: require('templates/main/admin/stack_upgrade')
 
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  }
 });

+ 2 - 18
ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js

@@ -18,24 +18,8 @@
 
 var App = require('app');
 
-App.AddAlertDefinitionView = Em.View.extend({
+App.AddAlertDefinitionView = Em.View.extend(App.WizardMenuMixin, {
 
-  templateName: require('templates/main/alerts/add_alert_definition/add_alert_definition'),
-
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  }
+  templateName: require('templates/main/alerts/add_alert_definition/add_alert_definition')
 
 });

+ 1 - 33
ambari-web/app/views/main/host/add_view.js

@@ -19,44 +19,12 @@
 
 var App = require('app');
 
-App.AddHostView = Em.View.extend({
+App.AddHostView = Em.View.extend(App.WizardMenuMixin, {
 
   templateName: require('templates/main/host/add'),
 
   isLoaded: false,
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.isStepDisabled(7);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  },
-
   willInsertElement: function () {
     if (this.get('controller').getDBProperty('hosts')) {
       this.set('isLoaded', true);

+ 1 - 33
ambari-web/app/views/main/service/add_view.js

@@ -19,44 +19,12 @@
 
 var App = require('app');
 
-App.AddServiceView = Em.View.extend({
+App.AddServiceView = Em.View.extend(App.WizardMenuMixin, {
 
   templateName: require('templates/main/service/add'),
 
   isLoaded: false,
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep7Disabled: function () {
-    return this.isStepDisabled(7);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  },
-
   willInsertElement: function () {
     this.loadHosts();
   },

+ 1 - 29
ambari-web/app/views/main/service/reassign_view.js

@@ -19,38 +19,10 @@
 
 var App = require('app');
 
-App.ReassignMasterView = Em.View.extend({
+App.ReassignMasterView = Em.View.extend(App.WizardMenuMixin, {
 
   templateName: require('templates/main/service/reassign'),
 
-  isStep1Disabled: function () {
-    return this.isStepDisabled(1);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep2Disabled: function () {
-    return this.isStepDisabled(2);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep3Disabled: function () {
-    return this.isStepDisabled(3);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep4Disabled: function () {
-    return this.isStepDisabled(4);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep5Disabled: function () {
-    return this.isStepDisabled(5);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStep6Disabled: function () {
-    return this.isStepDisabled(6);
-  }.property('controller.isStepDisabled.@each.value').cacheable(),
-
-  isStepDisabled: function (index) {
-    return this.get('controller.isStepDisabled').findProperty('step', index).get('value');
-  },
-
   isLoaded: false,
 
   willInsertElement: function() {

+ 103 - 0
ambari-web/test/mixins/wizard/wizard_menu_view_test.js

@@ -0,0 +1,103 @@
+/**
+ * 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.
+ */
+
+var App = require('app');
+
+var view;
+
+describe('App.WizardMenuMixin', function () {
+
+  beforeEach(function () {
+    view = Em.View.create(App.WizardMenuMixin, {
+      controller: Em.Object.create({
+        isStepDisabled: []
+      })
+    });
+  });
+
+  describe("#isStepDisabled()", function () {
+    it("step 1 disabled", function () {
+      view.set('controller.isStepDisabled', [Em.Object.create({
+        step: 1,
+        value: true
+      })]);
+      expect(view.isStepDisabled(1)).to.be.true;
+    });
+  });
+
+  describe("#isStep#Disabled", function () {
+    var testCases = [
+      {
+        property: 'isStep0Disabled',
+        step: 0
+      },
+      {
+        property: 'isStep1Disabled',
+        step: 1
+      },
+      {
+        property: 'isStep2Disabled',
+        step: 2
+      },
+      {
+        property: 'isStep3Disabled',
+        step: 3
+      },
+      {
+        property: 'isStep4Disabled',
+        step: 4
+      },
+      {
+        property: 'isStep5Disabled',
+        step: 5
+      },
+      {
+        property: 'isStep6Disabled',
+        step: 6
+      },
+      {
+        property: 'isStep7Disabled',
+        step: 7
+      },
+      {
+        property: 'isStep8Disabled',
+        step: 8
+      },
+      {
+        property: 'isStep9Disabled',
+        step: 9
+      },
+      {
+        property: 'isStep10Disabled',
+        step: 10
+      }
+    ];
+
+    testCases.forEach(function (test) {
+      it("step" + test.step + " disabled", function () {
+        view.set('controller.isStepDisabled', [Em.Object.create({
+          step: test.step,
+          value: true
+        })]);
+        view.propertyDidChange(test.property);
+        expect(view.get(test.property)).to.be.true;
+      });
+    }, this);
+  });
+
+});

+ 0 - 62
ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js

@@ -132,66 +132,4 @@ describe('App.HighAvailabilityWizardView', function () {
       expect(view.get('controller').setLowerStepsDisable.calledWith(5)).to.be.true;
     });
   });
-
-  describe("#isStepDisabled()", function () {
-    it("step 1 disabled", function () {
-      view.set('controller.isStepDisabled', [Em.Object.create({
-        step: 1,
-        value: true
-      })]);
-      expect(view.isStepDisabled(1)).to.be.true;
-    });
-  });
-
-  describe("#isStep#Disabled", function () {
-    var testCases = [
-      {
-        property: 'isStep1Disabled',
-        step: 1
-      },
-      {
-        property: 'isStep2Disabled',
-        step: 2
-      },
-      {
-        property: 'isStep3Disabled',
-        step: 3
-      },
-      {
-        property: 'isStep4Disabled',
-        step: 4
-      },
-      {
-        property: 'isStep5Disabled',
-        step: 5
-      },
-      {
-        property: 'isStep6Disabled',
-        step: 6
-      },
-      {
-        property: 'isStep7Disabled',
-        step: 7
-      },
-      {
-        property: 'isStep8Disabled',
-        step: 8
-      },
-      {
-        property: 'isStep9Disabled',
-        step: 9
-      }
-    ];
-
-    testCases.forEach(function (test) {
-      it("step" + test.step + " disabled", function () {
-        view.set('controller.isStepDisabled', [Em.Object.create({
-          step: test.step,
-          value: true
-        })]);
-        view.propertyDidChange(test.property);
-        expect(view.get(test.property)).to.be.true;
-      });
-    }, this);
-  });
 });