Repository: ambari Updated Branches: refs/heads/trunk 53583b2df -> ecd7d092b
AMBARI-14255 Restart All Required button can be clicked even if it is disabled (akovalenko) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/ecd7d092 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/ecd7d092 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/ecd7d092 Branch: refs/heads/trunk Commit: ecd7d092beab85aa3ab4c666d7ea7d402a5c19a6 Parents: 53583b2 Author: Aleksandr Kovalenko <akovale...@hortonworks.com> Authored: Mon Dec 7 19:56:25 2015 +0200 Committer: Aleksandr Kovalenko <akovale...@hortonworks.com> Committed: Mon Dec 7 19:56:25 2015 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/service.js | 24 ++++++++++++-------- .../test/controllers/main/service_test.js | 13 ++++++++++- 2 files changed, 26 insertions(+), 11 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd7d092/ambari-web/app/controllers/main/service.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/service.js b/ambari-web/app/controllers/main/service.js index 93bf8a1..1005533 100644 --- a/ambari-web/app/controllers/main/service.js +++ b/ambari-web/app/controllers/main/service.js @@ -301,17 +301,21 @@ App.MainServiceController = Em.ArrayController.extend({ var self = this; var servicesList = []; var hostComponentsToRestart = []; - App.HostComponent.find().filterProperty('staleConfigs').forEach(function (hostComponent) { - hostComponentsToRestart.push({ - component_name: hostComponent.get('componentName'), - service_name: hostComponent.get('service.serviceName'), - hosts: hostComponent.get('hostName') + if (!this.get('isRestartAllRequiredDisabled')) { + App.HostComponent.find().filterProperty('staleConfigs').forEach(function (hostComponent) { + hostComponentsToRestart.push({ + component_name: hostComponent.get('componentName'), + service_name: hostComponent.get('service.serviceName'), + hosts: hostComponent.get('hostName') + }); + servicesList.push(hostComponent.get('service.displayName')); }); - servicesList.push(hostComponent.get('service.displayName')); - }); - return App.showConfirmationPopup(function () { - self.restartHostComponents(hostComponentsToRestart); - }, Em.I18n.t('services.service.refreshAll.confirmMsg').format(servicesList.uniq().join(', ')), null, null, Em.I18n.t('services.service.restartAll.confirmButton')); + return App.showConfirmationPopup(function () { + self.restartHostComponents(hostComponentsToRestart); + }, Em.I18n.t('services.service.refreshAll.confirmMsg').format(servicesList.uniq().join(', ')), null, null, Em.I18n.t('services.service.restartAll.confirmButton')); + } else { + return null; + } }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/ecd7d092/ambari-web/test/controllers/main/service_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/service_test.js b/ambari-web/test/controllers/main/service_test.js index 2cbaf29..cad39f9 100644 --- a/ambari-web/test/controllers/main/service_test.js +++ b/ambari-web/test/controllers/main/service_test.js @@ -393,7 +393,11 @@ describe('App.MainServiceController', function () { }); it('should show confirmation popup with list of services and call restartHostComponents after confirmation', function () { - var popup = mainServiceController.restartAllRequired(); + var popup; + mainServiceController.reopen({ + isRestartAllRequiredDisabled: false + }); + popup = mainServiceController.restartAllRequired(); popup.onPrimary(); expect(App.showConfirmationPopup.args[0][1]).to.equal(Em.I18n.t('services.service.refreshAll.confirmMsg').format('displayName1, displayName2')); expect(mainServiceController.restartHostComponents.calledWith([ @@ -410,6 +414,13 @@ describe('App.MainServiceController', function () { ])).to.be.true; }); + it('should not open popup if isRestartAllRequiredDisabled is true', function(){ + mainServiceController.reopen({ + isRestartAllRequiredDisabled: true + }); + expect(mainServiceController.restartAllRequired()).to.be.null; + }); + }); describe('#restartHostComponents', function () {