ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-14716 Prevent the user from removing the last service. (atkach)
Date Tue, 19 Jan 2016 10:33:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 869e0858c -> 39400f4e9


AMBARI-14716 Prevent the user from removing the last service. (atkach)


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

Branch: refs/heads/trunk
Commit: 39400f4e97233a9d19391a28a0e47008a270d316
Parents: 869e085
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Tue Jan 19 11:37:45 2016 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Tue Jan 19 11:37:45 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/service/item.js | 25 +++++++++++++-------
 ambari-web/app/messages.js                      |  3 ++-
 .../test/controllers/main/service/item_test.js  | 12 ++++++++++
 3 files changed, 31 insertions(+), 9 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/39400f4e/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 260b1d2..2c1d4cc 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -954,26 +954,35 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
    */
   deleteService: function(serviceName) {
     var dependentServices = App.StackService.find(serviceName).get('requiredServices').filter(function(_serviceName)
{
-      return App.Service.find(_serviceName).get('isLoaded');
-    });
-    var self = this;
-    var displayName = App.format.role(serviceName);
-
-    if (dependentServices.length > 0) {
+          return App.Service.find(_serviceName).get('isLoaded');
+        }),
+        self = this,
+        displayName = App.format.role(serviceName),
+        popupHeader = Em.I18n.t('services.service.delete.popup.header');
+
+    if (App.Service.find().get('length') === 1) {
+      //at least one service should be installed
+      App.ModalPopup.show({
+        secondary: null,
+        header: popupHeader,
+        encodeBody: false,
+        body: Em.I18n.t('services.service.delete.lastService.popup.body').format(displayName)
+      });
+    } else if (dependentServices.length > 0) {
       this.dependentServicesWarning(serviceName, dependentServices);
     } else if (App.Service.find(serviceName).get('workStatus') === 'INSTALLED') {
       App.showConfirmationPopup(
         function() {self.confirmDeleteService(serviceName)},
         Em.I18n.t('services.service.delete.popup.warning').format(displayName),
         null,
-        Em.I18n.t('services.service.delete.popup.header'),
+        popupHeader,
         Em.I18n.t('common.delete'),
         true
       );
     } else {
       App.ModalPopup.show({
         secondary: null,
-        header: Em.I18n.t('services.service.delete.popup.header'),
+        header: popupHeader,
         encodeBody: false,
         body: Em.I18n.t('services.service.delete.popup.mustBeStopped').format(displayName)
       });

http://git-wip-us.apache.org/repos/asf/ambari/blob/39400f4e/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 203e7ee..82797a7 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1679,10 +1679,11 @@ Em.I18n.translations = {
   'services.service.actions.serviceActions':'Service Actions',
 
   'services.service.delete.popup.header': 'Delete Service',
+  'services.service.delete.lastService.popup.body': 'The <b>{0}</b> service can\'t
be deleted, at least one service must be installed.',
   'services.service.delete.popup.dependentServices': 'Prior to deleting <b>{0}</b>,
you must delete the following dependent services:',
   'services.service.delete.popup.mustBeStopped': 'Prior to deleting <b>{0}</b>,
you must stop the service.',
   'services.service.delete.popup.warning': 'The <b>{0} service will be removed from
Ambari and all configurations' +
-  ' and configuration history will be lost</b>',
+  ' and configuration history will be lost.</b>',
   'services.service.confirmDelete.popup.header': 'Confirm Delete',
   'services.service.confirmDelete.popup.body': 'You must confirm delete of <b>{0}</b>
by typing "yes"' +
   ' in the confirmation box. <b>This operation is not reversible and all configuration
history will be lost.</b>',

http://git-wip-us.apache.org/repos/asf/ambari/blob/39400f4e/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 98ff890..55d27f7 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1197,6 +1197,18 @@ describe('App.MainServiceItemController', function () {
       App.format.role.restore();
     });
 
+    it("only one service installed", function() {
+      this.mockStackService.returns(Em.Object.create({requiredServices: ['S2']}));
+      this.mockService.returns(Em.Object.create({length: 1}));
+      mainServiceItemController.deleteService('S1');
+      expect(App.ModalPopup.show.calledWith({
+        secondary: null,
+        header: Em.I18n.t('services.service.delete.popup.header'),
+        encodeBody: false,
+        body: Em.I18n.t('services.service.delete.lastService.popup.body').format('S1')
+      })).to.be.true;
+    });
+
     it("service has installed dependent services", function() {
       this.mockStackService.returns(Em.Object.create({requiredServices: ['S2']}));
       this.mockService.returns(Em.Object.create({workStatus: 'INSTALLED', isLoaded: true}));


Mime
View raw message