Repository: ambari Updated Branches: refs/heads/branch-2.1 e145d605f -> 7f835344d
AMBARI-13468. Strange behavior on Customize Services -> Review transition (onechiporenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/7f835344 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/7f835344 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/7f835344 Branch: refs/heads/branch-2.1 Commit: 7f835344d36edac4189dac634c6abfe42da28306 Parents: e145d60 Author: Oleg Nechiporenko <onechipore...@apache.org> Authored: Mon Oct 19 13:49:53 2015 +0300 Committer: Oleg Nechiporenko <onechipore...@apache.org> Committed: Mon Oct 19 13:49:53 2015 +0300 ---------------------------------------------------------------------- ambari-web/app/controllers/wizard.js | 7 ++ .../app/controllers/wizard/step7_controller.js | 79 +++++++++++----- .../test/controllers/wizard/step7_test.js | 96 +++++++++++++++++++- 3 files changed, 155 insertions(+), 27 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/7f835344/ambari-web/app/controllers/wizard.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js index fb6bd44..ad78d8c 100644 --- a/ambari-web/app/controllers/wizard.js +++ b/ambari-web/app/controllers/wizard.js @@ -210,6 +210,13 @@ App.WizardController = Em.Controller.extend(App.LocalStorage, App.ThemesMappingM return this.get('currentStep') == 10; }.property('currentStep'), + /** + * Move user to the selected step + * + * @param {number} step number of the step, where user is moved + * @param {boolean} disableNaviWarning true - don't show warning about moving more than 1 step back + * @returns {boolean} + */ gotoStep: function (step, disableNaviWarning) { if (this.get('isStepDisabled').findProperty('step', step).get('value') !== false) { return false; http://git-wip-us.apache.org/repos/asf/ambari/blob/7f835344/ambari-web/app/controllers/wizard/step7_controller.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js index 189d700..f4c4a4e 100644 --- a/ambari-web/app/controllers/wizard/step7_controller.js +++ b/ambari-web/app/controllers/wizard/step7_controller.js @@ -1268,9 +1268,9 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E getAmbariDatabaseSuccess: function (data) { var hiveDBHostname = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_hostname').value; var ambariServiceHostComponents = data.hostComponents; - if (!!ambariServiceHostComponents.length) { + if (ambariServiceHostComponents.length) { var ambariDBInfo = JSON.stringify(ambariServiceHostComponents[0].RootServiceHostComponents.properties); - this.set('mySQLServerConflict', ambariDBInfo.indexOf('mysql') > 0 && ambariDBInfo.indexOf(hiveDBHostname) > 0); + this.set('mySQLServerConflict', ambariDBInfo.contains('mysql') && ambariDBInfo.indexOf(hiveDBHostname) > 0); } else { this.set('mySQLServerConflict', false); } @@ -1292,34 +1292,63 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E var hiveDBType = this.get('stepConfigs').findProperty('serviceName', 'HIVE').configs.findProperty('name', 'hive_database').value; if (hiveDBType == 'New MySQL Database') { var self = this; - this.checkMySQLHost().done(function () { - if (self.get('mySQLServerConflict')) { - // error popup before you can proceed + return this.checkMySQLHost().done(function () { + self.mySQLWarningHandler(); + }); + } + else { + this.moveNext(); + } + }, + + /** + * Show warning popup about MySQL-DB issues (on post-submit) + * + * @returns {*} + * @method mySQLWarningHandler + */ + mySQLWarningHandler: function () { + var self = this; + if (this.get('mySQLServerConflict')) { + // error popup before you can proceed + return App.ModalPopup.show({ + header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'), + body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'), + secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'), + primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'), + encodeBody: false, + onPrimary: function () { + this._super(); + self.set('submitButtonClicked', false); + }, + onSecondary: function () { + var parent = this; return App.ModalPopup.show({ - header: Em.I18n.t('installer.step7.popup.mySQLWarning.header'), - body:Em.I18n.t('installer.step7.popup.mySQLWarning.body'), - secondary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.gotostep5'), - primary: Em.I18n.t('installer.step7.popup.mySQLWarning.button.dismiss'), - onSecondary: function () { - var parent = this; - return App.ModalPopup.show({ - header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'), - body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'), - onPrimary: function () { - this.hide(); - parent.hide(); - // go back to step 5: assign masters and disable default navigation warning - App.router.get('installerController').gotoStep(5, true); + header: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.header'), + body: Em.I18n.t('installer.step7.popup.mySQLWarning.confirmation.body'), + onPrimary: function () { + this.hide(); + parent.hide(); + // go back to step 5: assign masters and disable default navigation warning + if ('installerController' === self.get('content.controllerName')) { + App.router.get('installerController').gotoStep(5, true); + } + else { + if ('addServiceController' === self.get('content.controllerName')) { + App.router.get('addServiceController').gotoStep(2, true); } - }); + } + }, + onSecondary: function () { + this._super(); + self.set('submitButtonClicked', false); } }); - } else { - self.moveNext(); } }); - } else { - this.moveNext(); + } + else { + return this.moveNext(); } }, @@ -1442,6 +1471,7 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E **/ moveNext: function () { App.router.send('next'); + this.set('submitButtonClicked', false); }, /** @@ -1488,7 +1518,6 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, App.E this.showOozieDerbyWarningPopup(function() { self.checkDatabaseConnectionTest().done(function () { self.resolveHiveMysqlDatabase(); - self.set('submitButtonClicked', false); }); }); }, http://git-wip-us.apache.org/repos/asf/ambari/blob/7f835344/ambari-web/test/controllers/wizard/step7_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/wizard/step7_test.js b/ambari-web/test/controllers/wizard/step7_test.js index 0a5c621..97470aa 100644 --- a/ambari-web/test/controllers/wizard/step7_test.js +++ b/ambari-web/test/controllers/wizard/step7_test.js @@ -102,10 +102,10 @@ describe('App.InstallerStep7Controller', function () { beforeEach(function () { sinon.stub(App.config, 'setPreDefinedServiceConfigs', Em.K); installerStep7Controller = App.WizardStep7Controller.create({ - content: { + content: Em.Object.create({ advancedServiceConfig: [], serviceConfigProperties: [] - } + }) }); }); @@ -2138,4 +2138,96 @@ describe('App.InstallerStep7Controller', function () { }); + describe('#resolveHiveMysqlDatabase', function () { + + beforeEach(function () { + installerStep7Controller.get('content').setProperties({ + services: Em.A([ + Em.Object.create({serviceName: 'HIVE', isSelected: true, isInstalled: false}) + ]) + }); + installerStep7Controller.setProperties({ + stepConfigs: Em.A([ + Em.Object.create({serviceName: 'HIVE', configs: [{name: 'hive_database', value: 'New MySQL Database'}]}) + ]), + mySQLServerConflict: true + }); + sinon.stub(installerStep7Controller, 'moveNext', Em.K); + sinon.stub(installerStep7Controller, 'checkMySQLHost', function () { + return $.Deferred().resolve(); + }); + sinon.spy(App.ModalPopup, 'show'); + }); + + afterEach(function () { + installerStep7Controller.moveNext.restore(); + installerStep7Controller.checkMySQLHost.restore(); + + App.ModalPopup.show.restore(); + }); + + it('no HIVE service', function () { + installerStep7Controller.set('content.services', Em.A([])); + installerStep7Controller.resolveHiveMysqlDatabase(); + expect(installerStep7Controller.moveNext.calledOnce).to.be.true; + expect(App.ModalPopup.show.called).to.be.false; + }); + + it('if mySQLServerConflict, popup is shown', function () { + installerStep7Controller.resolveHiveMysqlDatabase(); + expect(installerStep7Controller.moveNext.called).to.be.false; + expect(App.ModalPopup.show.calledOnce).to.be.true; + }); + + }); + + describe('#mySQLWarningHandler', function () { + + beforeEach(function () { + installerStep7Controller.set('mySQLServerConflict', true); + sinon.spy(App.ModalPopup, 'show'); + sinon.stub(App.router, 'get').returns({gotoStep: Em.K}); + sinon.stub(App.router.get(), 'gotoStep', Em.K); + }); + + afterEach(function () { + App.ModalPopup.show.restore(); + App.router.get().gotoStep.restore(); + App.router.get.restore(); + }); + + it('warning popup is shown', function () { + installerStep7Controller.mySQLWarningHandler(); + expect(App.ModalPopup.show.calledOnce).to.be.true; + }); + + it('submitButtonClicked is set to false on primary click', function () { + installerStep7Controller.mySQLWarningHandler().onPrimary(); + expect(installerStep7Controller.get('submitButtonClicked')).to.be.false; + }); + + it('second popup is shown on secondary click', function () { + installerStep7Controller.mySQLWarningHandler().onSecondary(); + expect(App.ModalPopup.show.calledTwice).to.be.true; + }); + + it('submitButtonClicked is set to false on secondary click on the second popup', function () { + installerStep7Controller.mySQLWarningHandler().onSecondary().onSecondary(); + expect(installerStep7Controller.get('submitButtonClicked')).to.be.false; + }); + + it('user is moved to step5 on primary click on the second popup (installerController)', function () { + installerStep7Controller.set('content.controllerName', 'installerController'); + installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary(); + expect(App.router.get('installerController').gotoStep.calledWith(5, true)).to.be.true; + }); + + it('user is moved to step2 on primary click on the second popup (addSeviceController)', function () { + installerStep7Controller.set('content.controllerName', 'addServiceController'); + installerStep7Controller.mySQLWarningHandler().onSecondary().onPrimary(); + expect(App.router.get('addSeviceController').gotoStep.calledWith(2, true)).to.be.true; + }); + + }); + });