Repository: ambari Updated Branches: refs/heads/trunk 81d5c7bdf -> b4dd68dac
AMBARI-8440. Create mixins for wizard views (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b4dd68da Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b4dd68da Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b4dd68da Branch: refs/heads/trunk Commit: b4dd68dacf69fa30d44108fc755bbe79b118ae90 Parents: 81d5c7b Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Tue Nov 25 12:56:15 2014 +0200 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Tue Nov 25 12:56:15 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/assets/test/tests.js | 3 +- ambari-web/app/mixins.js | 1 + .../app/mixins/wizard/wizard_menu_view.js | 72 +++++++++++++ ambari-web/app/router.js | 24 +++++ .../app/routes/add_alert_definition_routes.js | 8 +- ambari-web/app/routes/add_host_routes.js | 16 +-- ambari-web/app/routes/add_kerberos_routes.js | 15 +-- ambari-web/app/routes/add_security.js | 10 +- ambari-web/app/routes/add_service_routes.js | 14 --- .../app/routes/high_availability_routes.js | 19 +--- ambari-web/app/routes/reassign_master_routes.js | 13 --- .../app/routes/rm_high_availability_routes.js | 9 +- ambari-web/app/routes/rollbackHA_routes.js | 8 +- ambari-web/app/routes/stack_upgrade.js | 8 +- ambari-web/app/views/installer.js | 48 +-------- .../nameNode/rollbackHA/rollback_wizard_view.js | 22 +--- .../highAvailability/nameNode/wizard_view.js | 45 +------- .../resourceManager/wizard_view.js | 22 +--- .../views/main/admin/kerberos/wizard_view.js | 18 +--- .../app/views/main/admin/security/add/menu.js | 20 +--- .../app/views/main/admin/stack_upgrade.js | 18 +--- .../add_alert_definition_view.js | 20 +--- ambari-web/app/views/main/host/add_view.js | 34 +----- ambari-web/app/views/main/service/add_view.js | 34 +----- .../app/views/main/service/reassign_view.js | 30 +----- .../test/mixins/wizard/wizard_menu_view_test.js | 103 +++++++++++++++++++ .../nameNode/wizard_view_test.js | 62 ----------- 27 files changed, 229 insertions(+), 467 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/assets/test/tests.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/assets/test/tests.js b/ambari-web/app/assets/test/tests.js index e7ba360..3d98fec 100644 --- a/ambari-web/app/assets/test/tests.js +++ b/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', http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/mixins.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins.js b/ambari-web/app/mixins.js index a1016b3..4ac2dce 100644 --- a/ambari-web/app/mixins.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/mixins/wizard/wizard_menu_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/mixins/wizard/wizard_menu_view.js b/ambari-web/app/mixins/wizard/wizard_menu_view.js new file mode 100644 index 0000000..1a8016a --- /dev/null +++ b/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() + +}); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/router.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js index d6791f5..bf27c7d 100644 --- a/ambari-web/app/router.js +++ b/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({ http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/add_alert_definition_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_alert_definition_routes.js b/ambari-web/app/routes/add_alert_definition_routes.js index ef44d2a..0b30340 100644 --- a/ambari-web/app/routes/add_alert_definition_routes.js +++ b/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') + }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/add_host_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_host_routes.js b/ambari-web/app/routes/add_host_routes.js index 2abbff6..f8cdadd 100644 --- a/ambari-web/app/routes/add_host_routes.js +++ b/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') + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/add_kerberos_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_kerberos_routes.js b/ambari-web/app/routes/add_kerberos_routes.js index 028e11d..4afaedb 100644 --- a/ambari-web/app/routes/add_kerberos_routes.js +++ b/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') + }) }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/add_security.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_security.js b/ambari-web/app/routes/add_security.js index cca41a6..dce4bed 100644 --- a/ambari-web/app/routes/add_security.js +++ b/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') + }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/add_service_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/add_service_routes.js b/ambari-web/app/routes/add_service_routes.js index 5069c83..d0421a8 100644 --- a/ambari-web/app/routes/add_service_routes.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/high_availability_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/high_availability_routes.js b/ambari-web/app/routes/high_availability_routes.js index 93a3ca1..be8a575 100644 --- a/ambari-web/app/routes/high_availability_routes.js +++ b/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') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/reassign_master_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/reassign_master_routes.js b/ambari-web/app/routes/reassign_master_routes.js index e6ef5ca..43563ea 100644 --- a/ambari-web/app/routes/reassign_master_routes.js +++ b/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'); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/rm_high_availability_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/rm_high_availability_routes.js b/ambari-web/app/routes/rm_high_availability_routes.js index 3d31533..e15ee13 100644 --- a/ambari-web/app/routes/rm_high_availability_routes.js +++ b/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') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/rollbackHA_routes.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/rollbackHA_routes.js b/ambari-web/app/routes/rollbackHA_routes.js index 99e893e..f9c9f11 100644 --- a/ambari-web/app/routes/rollbackHA_routes.js +++ b/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') + }) }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/routes/stack_upgrade.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/routes/stack_upgrade.js b/ambari-web/app/routes/stack_upgrade.js index 3d7c4bf..b461499 100644 --- a/ambari-web/app/routes/stack_upgrade.js +++ b/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') + } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/installer.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/installer.js b/ambari-web/app/views/installer.js index b10e3c7..ba5741d 100644 --- a/ambari-web/app/views/installer.js +++ b/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') }); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js b/ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js index 723420a..b8e1588 100644 --- a/ambari-web/app/views/main/admin/highAvailability/nameNode/rollbackHA/rollback_wizard_view.js +++ b/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'); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js b/ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js index 5766aa6..149770e 100644 --- a/ambari-web/app/views/main/admin/highAvailability/nameNode/wizard_view.js +++ b/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'); } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js b/ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js index bfc1fb1..cf03660 100644 --- a/ambari-web/app/views/main/admin/highAvailability/resourceManager/wizard_view.js +++ b/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() { http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/kerberos/wizard_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/kerberos/wizard_view.js b/ambari-web/app/views/main/admin/kerberos/wizard_view.js index 708c649..d82786a 100644 --- a/ambari-web/app/views/main/admin/kerberos/wizard_view.js +++ b/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, http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/security/add/menu.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/security/add/menu.js b/ambari-web/app/views/main/admin/security/add/menu.js index d41baa9..628c6ed 100644 --- a/ambari-web/app/views/main/admin/security/add/menu.js +++ b/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') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/admin/stack_upgrade.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/admin/stack_upgrade.js b/ambari-web/app/views/main/admin/stack_upgrade.js index d2328c9..ffa3609 100644 --- a/ambari-web/app/views/main/admin/stack_upgrade.js +++ b/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'); - } }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js b/ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js index dde686c..6ffc988 100644 --- a/ambari-web/app/views/main/alerts/add_alert_definition/add_alert_definition_view.js +++ b/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') }); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/host/add_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/add_view.js b/ambari-web/app/views/main/host/add_view.js index 8f3cae1..33fd123 100644 --- a/ambari-web/app/views/main/host/add_view.js +++ b/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); http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/service/add_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/add_view.js b/ambari-web/app/views/main/service/add_view.js index 032ca5c..78b6978 100644 --- a/ambari-web/app/views/main/service/add_view.js +++ b/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(); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/app/views/main/service/reassign_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/service/reassign_view.js b/ambari-web/app/views/main/service/reassign_view.js index a90332a..47f1860 100644 --- a/ambari-web/app/views/main/service/reassign_view.js +++ b/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() { http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/test/mixins/wizard/wizard_menu_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/mixins/wizard/wizard_menu_view_test.js b/ambari-web/test/mixins/wizard/wizard_menu_view_test.js new file mode 100644 index 0000000..8a78dec --- /dev/null +++ b/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); + }); + +}); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/ambari/blob/b4dd68da/ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js b/ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js index 09312de..3abfbdb 100644 --- a/ambari-web/test/views/main/admin/highAvailability/nameNode/wizard_view_test.js +++ b/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); - }); }); \ No newline at end of file