Repository: ambari
Updated Branches:
  refs/heads/trunk 96517a9b1 -> db0aa3e14


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/db0aa3e1
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/db0aa3e1
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/db0aa3e1

Branch: refs/heads/trunk
Commit: db0aa3e1411d341919590b09cca8e0346a66b46a
Parents: 96517a9
Author: Jun Aoki <ja...@apache.org>
Authored: Tue Oct 28 12:58:58 2014 -0700
Committer: Jun Aoki <ja...@apache.org>
Committed: Tue Oct 28 12:58:58 2014 -0700

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service.js      |  7 +++++-
 ambari-web/app/controllers/main/service/item.js |  4 +--
 ambari-web/app/messages.js                      |  4 +++
 .../test/controllers/main/service/item_test.js  | 16 ++++++++++++
 .../test/controllers/main/service_test.js       | 26 ++++++++++++++++++++
 5 files changed, 54 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/db0aa3e1/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 a6d5983..c487931 100644
--- a/ambari-web/app/controllers/main/service.js
+++ b/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);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/db0aa3e1/ambari-web/app/controllers/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/item.js 
b/ambari-web/app/controllers/main/service/item.js
index 7339e77..2666032 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/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
     });
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/db0aa3e1/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 99a429c..d084630 100644
--- a/ambari-web/app/messages.js
+++ b/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}',

http://git-wip-us.apache.org/repos/asf/ambari/blob/db0aa3e1/ambari-web/test/controllers/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/item_test.js 
b/ambari-web/test/controllers/main/service/item_test.js
index 34e252f..5caf5d3 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/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 () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/db0aa3e1/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 9ffd7a3..61c0e3e 100644
--- a/ambari-web/test/controllers/main/service_test.js
+++ b/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() {

Reply via email to