瀏覽代碼

AMBARI-7663 Confirmation dialogues needs clearer messages regarding actions on services (salvi via jaoki)

Jun Aoki 10 年之前
父節點
當前提交
db0aa3e141

+ 6 - 1
ambari-web/app/controllers/main/service.js

@@ -117,9 +117,14 @@ App.MainServiceController = Em.ArrayController.extend({
       return null;
     }
     var self = this;
+    var bodyMessage = Em.Object.create({
+      confirmMsg: state == 'INSTALLED' ? Em.I18n.t('services.service.stopAll.confirmMsg') : Em.I18n.t('services.service.startAll.confirmMsg'),
+      confirmButton: state == 'INSTALLED' ? Em.I18n.t('services.service.stop.confirmButton') : Em.I18n.t('services.service.start.confirmButton')
+    });
+
     return App.showConfirmationFeedBackPopup(function (query) {
       self.allServicesCall(state, query);
-    });
+    }, bodyMessage);
   },
 
   /**

+ 2 - 2
ambari-web/app/controllers/main/service/item.js

@@ -165,8 +165,8 @@ App.MainServiceItemController = Em.Controller.extend({
     var bodyMessage = Em.Object.create({
       putInMaintenance: (serviceHealth == 'INSTALLED' && isMaintenanceOFF) || (serviceHealth == 'STARTED' && !isMaintenanceOFF),
       turnOnMmMsg: serviceHealth == 'INSTALLED' ? Em.I18n.t('passiveState.turnOnFor').format(serviceDisplayName) : Em.I18n.t('passiveState.turnOffFor').format(serviceDisplayName),
-      confirmMsg: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmMsg').format(serviceDisplayName) : Em.I18n.t('question.sure'),
-      confirmButton: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmButton') : Em.I18n.t('ok'),
+      confirmMsg: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmMsg').format(serviceDisplayName) : Em.I18n.t('services.service.start.confirmMsg').format(serviceDisplayName),
+      confirmButton: serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.confirmButton') : Em.I18n.t('services.service.start.confirmButton'),
       additionalWarningMsg:  isMaintenanceOFF && serviceHealth == 'INSTALLED'? Em.I18n.t('services.service.stop.warningMsg.turnOnMM').format(serviceDisplayName) : null
     });
 

+ 4 - 0
ambari-web/app/messages.js

@@ -1460,8 +1460,12 @@ Em.I18n.translations = {
   'services.service.add':'Add Service',
   'services.service.startAll':'Start All',
   'services.service.stopAll':'Stop All',
+  'services.service.startAll.confirmMsg' : 'You are about to start all services',
+  'services.service.stopAll.confirmMsg' : 'You are about to stop all services',
+  'services.service.start.confirmMsg' : 'You are about to start {0}',
   'services.service.stop.confirmMsg' : 'You are about to stop {0}',
   'services.service.stop.confirmButton': 'Confirm Stop',
+  'services.service.start.confirmButton' : 'Confirm Start',
   'services.service.stop.warningMsg.turnOnMM': 'This will generate alerts as the service is stopped. To suppress alerts, turn on Maintenance Mode for {0} prior to stopping',
   'services.service.restartAll.confirmButton': 'Confirm Restart All',
   'services.service.restartAll.confirmMsg': 'You are about to restart {0}',

+ 16 - 0
ambari-web/test/controllers/main/service/item_test.js

@@ -395,14 +395,30 @@ describe('App.MainServiceItemController', function () {
     var mainServiceItemController = App.MainServiceItemController.create({content: {serviceName: "HDFS"}});
     beforeEach(function () {
       sinon.spy(mainServiceItemController, "startStopPopupPrimary");
+      sinon.spy(Em.I18n, "t");
     });
     afterEach(function () {
       mainServiceItemController.startStopPopupPrimary.restore();
+      Em.I18n.t.restore();
     });
     it("start start/stop service popup", function () {
       mainServiceItemController.startStopPopup(event, "").onPrimary();
       expect(mainServiceItemController.startStopPopupPrimary.calledOnce).to.equal(true);
     });
+
+    describe("modal messages", function() {
+      it ("should confirm stop if serviceHealth is INSTALLED", function() {
+        mainServiceItemController.startStopPopup(event, "INSTALLED");
+        expect(Em.I18n.t.calledWith('services.service.stop.confirmMsg')).to.be.ok;
+        expect(Em.I18n.t.calledWith('services.service.stop.confirmButton')).to.be.ok;
+      });
+
+      it ("should confirm start if serviceHealth is not INSTALLED", function() {
+        mainServiceItemController.startStopPopup(event, "");
+        expect(Em.I18n.t.calledWith('services.service.start.confirmMsg')).to.be.ok;
+        expect(Em.I18n.t.calledWith('services.service.start.confirmButton')).to.be.ok;
+      });
+    });
   });
 
   describe("#restartAllHostComponents", function () {

+ 26 - 0
ambari-web/test/controllers/main/service_test.js

@@ -216,6 +216,32 @@ describe('App.MainServiceController', function () {
 
   });
 
+  describe('#startStopAllService', function() {
+    var event = { target: document.createElement("BUTTON") };
+
+    beforeEach(function() {
+      sinon.stub(mainServiceController, 'allServicesCall', Em.K);
+      sinon.spy(Em.I18n, "t");
+    });
+
+    afterEach(function() {
+      mainServiceController.allServicesCall.restore();
+      Em.I18n.t.restore();
+    });
+
+    it ("should confirm stop if state is INSTALLED", function() {
+      mainServiceController.startStopAllService(event, "INSTALLED");
+      expect(Em.I18n.t.calledWith('services.service.stopAll.confirmMsg')).to.be.ok;
+      expect(Em.I18n.t.calledWith('services.service.stop.confirmButton')).to.be.ok;
+    });
+
+    it ("should confirm start if state is not INSTALLED", function() {
+      mainServiceController.startStopAllService(event, "STARTED");
+      expect(Em.I18n.t.calledWith('services.service.startAll.confirmMsg')).to.be.ok;
+      expect(Em.I18n.t.calledWith('services.service.start.confirmButton')).to.be.ok;
+    });
+  });
+
   describe('#allServicesCall', function() {
 
     beforeEach(function() {