Kaynağa Gözat

AMBARI-14255 Restart All Required button can be clicked even if it is disabled (akovalenko)

Aleksandr Kovalenko 9 yıl önce
ebeveyn
işleme
ecd7d092be

+ 14 - 10
ambari-web/app/controllers/main/service.js

@@ -301,17 +301,21 @@ App.MainServiceController = Em.ArrayController.extend({
     var self = this;
     var self = this;
     var servicesList = [];
     var servicesList = [];
     var hostComponentsToRestart = [];
     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;
+    }
   },
   },
 
 
   /**
   /**

+ 12 - 1
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 () {
     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();
       popup.onPrimary();
       expect(App.showConfirmationPopup.args[0][1]).to.equal(Em.I18n.t('services.service.refreshAll.confirmMsg').format('displayName1, displayName2'));
       expect(App.showConfirmationPopup.args[0][1]).to.equal(Em.I18n.t('services.service.refreshAll.confirmMsg').format('displayName1, displayName2'));
       expect(mainServiceController.restartHostComponents.calledWith([
       expect(mainServiceController.restartHostComponents.calledWith([
@@ -410,6 +414,13 @@ describe('App.MainServiceController', function () {
       ])).to.be.true;
       ])).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 () {
   describe('#restartHostComponents', function () {