Repository: ambari
Updated Branches:
  refs/heads/trunk ef63373ef -> 9b21f30b5


AMBARI-19048 Delete service action should show the config recommendation popup. 
(ababiichuk)


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

Branch: refs/heads/trunk
Commit: 9b21f30b5f081d7b313f9070ae125afc84db7647
Parents: ef63373
Author: ababiichuk <ababiic...@hortonworks.com>
Authored: Thu Dec 1 16:00:31 2016 +0200
Committer: ababiichuk <ababiic...@hortonworks.com>
Committed: Thu Dec 1 17:07:49 2016 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    |  2 +-
 ambari-web/app/controllers/main/service/item.js | 49 ++++++++++++++------
 .../app/controllers/wizard/step7_controller.js  |  2 +-
 .../app/mixins/main/service/groups_mapping.js   |  2 +-
 .../info/delete_service_warning_popup.hbs       | 28 +++++++++++
 .../test/controllers/main/service/item_test.js  | 13 +++---
 6 files changed, 74 insertions(+), 22 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js 
b/ambari-web/app/controllers/main/service/info/configs.js
index 130b1b5..94caf4a 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -21,7 +21,7 @@ var batchUtils = require('utils/batch_scheduled_requests');
 
 App.MainServiceInfoConfigsController = 
Em.Controller.extend(App.AddSecurityConfigs, App.ConfigsLoader,
   App.ServerValidatorMixin, App.EnhancedConfigsMixin, App.ThemesMappingMixin, 
App.ConfigsSaverMixin,
-  App.ConfigsComparator, App.ComponentActionsByConfigs, App.TrackRequestMixin, 
{
+  App.ConfigsComparator, App.ComponentActionsByConfigs, {
 
   name: 'mainServiceInfoConfigsController',
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/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 18a121f..19b021b 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -21,7 +21,7 @@ var batchUtils = require('utils/batch_scheduled_requests');
 var blueprintUtils = require('utils/blueprint');
 var stringUtils = require('utils/string_utils');
 
-App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDownload, App.InstallComponent, 
App.ConfigsSaverMixin, App.EnhancedConfigsMixin, {
+App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDownload, App.InstallComponent, 
App.ConfigsSaverMixin, App.EnhancedConfigsMixin, App.GroupsMappingMixin, {
   name: 'mainServiceItemController',
 
   /**
@@ -86,6 +86,8 @@ App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDow
 
   deleteServiceProgressPopup: null,
 
+  isRecommendationInProgress: false,
+
   isClientsOnlyService: function() {
     return 
App.get('services.clientOnly').contains(this.get('content.serviceName'));
   }.property('content.serviceName'),
@@ -1317,17 +1319,38 @@ App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDow
   showLastWarning: function (serviceName, interDependentServices, 
dependentServicesToDeleteFmt) {
     var self = this,
       displayName = App.format.role(serviceName, true),
-      popupHeader = Em.I18n.t('services.service.delete.popup.header');
-
-    return App.showConfirmationPopup(
-      function() {self.confirmDeleteService(serviceName, 
interDependentServices, dependentServicesToDeleteFmt)},
-      Em.I18n.t('services.service.delete.popup.warning').format(displayName) +
-      (interDependentServices.length ? 
Em.I18n.t('services.service.delete.popup.warning.dependent').format(dependentServicesToDeleteFmt)
 : ''),
-      null,
-      popupHeader,
-      Em.I18n.t('common.delete'),
-      true
-    );
+      popupHeader = Em.I18n.t('services.service.delete.popup.header'),
+      popupPrimary = Em.I18n.t('common.delete'),
+      warningMessage = 
Em.I18n.t('services.service.delete.popup.warning').format(displayName) +
+        (interDependentServices.length ? 
Em.I18n.t('services.service.delete.popup.warning.dependent').format(dependentServicesToDeleteFmt)
 : '');
+    this.clearRecommendationsInfo();
+    this.setProperties({
+      isRecommendationInProgress: true,
+      selectedConfigGroup: Em.Object.create({
+        isDefault: true
+      })
+    });
+    this.loadConfigRecommendations(null, function () {
+      var serviceNames = 
self.get('changedProperties').mapProperty('serviceName').uniq();
+      self.loadConfigGroups(serviceNames).done(function () {
+        self.set('isRecommendationInProgress', false);
+      })
+    });
+    return App.ModalPopup.show({
+      controller: self,
+      header: popupHeader,
+      primary: popupPrimary,
+      primaryClass: 'btn-danger',
+      disablePrimary: 
Em.computed.alias('controller.isRecommendationInProgress'),
+      bodyClass: Em.View.extend({
+        templateName: 
require('templates/main/service/info/delete_service_warning_popup'),
+        warningMessage: new Em.Handlebars.SafeString(warningMessage)
+      }),
+      onPrimary: function () {
+        self.confirmDeleteService(serviceName, interDependentServices, 
dependentServicesToDeleteFmt);
+        this._super();
+      }
+    });
   },
 
   /**
@@ -1569,7 +1592,7 @@ App.MainServiceItemController = 
Em.Controller.extend(App.SupportClientConfigsDow
     if (params.servicesToDeleteNext) {
       this.deleteServiceCall(params.servicesToDeleteNext);
     } else {
-      this.loadConfigRecommendations(null, this.saveConfigs.bind(this));
+      this.saveConfigs();
     }
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js 
b/ambari-web/app/controllers/wizard/step7_controller.js
index d43b69b..0d30d12 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -42,7 +42,7 @@ var App = require('app');
  * @property {?object[]} slaveComponentHosts
  */
 
-App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, 
App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, 
App.TrackRequestMixin, {
+App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin, 
App.EnhancedConfigsMixin, App.ToggleIsRequiredMixin, App.GroupsMappingMixin, {
 
   name: 'wizardStep7Controller',
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/ambari-web/app/mixins/main/service/groups_mapping.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/main/service/groups_mapping.js 
b/ambari-web/app/mixins/main/service/groups_mapping.js
index df2fabf..0781aa3 100644
--- a/ambari-web/app/mixins/main/service/groups_mapping.js
+++ b/ambari-web/app/mixins/main/service/groups_mapping.js
@@ -23,7 +23,7 @@ var App = require('app');
  *
  * @type {Em.Mixin}
  */
-App.GroupsMappingMixin = Em.Mixin.create({
+App.GroupsMappingMixin = Em.Mixin.create(App.TrackRequestMixin, {
 
   /**
    * Load config groups

http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/ambari-web/app/templates/main/service/info/delete_service_warning_popup.hbs
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/templates/main/service/info/delete_service_warning_popup.hbs 
b/ambari-web/app/templates/main/service/info/delete_service_warning_popup.hbs
new file mode 100644
index 0000000..4155947
--- /dev/null
+++ 
b/ambari-web/app/templates/main/service/info/delete_service_warning_popup.hbs
@@ -0,0 +1,28 @@
+{{!
+* Licensed to the Apache Software Foundation (ASF) under one
+* or more contributor license agreements.  See the NOTICE file
+* distributed with this work for additional information
+* regarding copyright ownership.  The ASF licenses this file
+* to you under the Apache License, Version 2.0 (the
+* "License"); you may not use this file except in compliance
+* with the License.  You may obtain a copy of the License at
+*
+*     http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing, software
+* distributed under the License is distributed on an "AS IS" BASIS,
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+* See the License for the specific language governing permissions and
+* limitations under the License.
+}}
+
+{{view.warningMessage}}
+{{#if controller.isRecommendationInProgress}}
+  {{view App.SpinnerView}}
+{{else}}
+  {{#if controller.changedProperties.length}}
+    <div class="alert alert-warning">
+      <span>{{dependenciesMessage}}</span> <a href="#" {{action 
"showChangedDependentConfigs" target="controller"}}>{{t common.showDetails}}</a>
+    </div>
+  {{/if}}
+{{/if}}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/9b21f30b/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 082fbd9..a22733f 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -1380,6 +1380,7 @@ describe('App.MainServiceItemController', function () {
       sinon.stub(App.ModalPopup, 'show');
       sinon.stub(App.format, 'role', function(name) {return name});
       sinon.stub(mainServiceItemController, 'kerberosDeleteWarning');
+      sinon.stub(mainServiceItemController, 'showLastWarning');
 
       mainServiceItemController.reopen({
         interDependentServices: []
@@ -1439,7 +1440,7 @@ describe('App.MainServiceItemController', function () {
       this.allowUninstallServices.returns(true);
       this.mockService.returns([Em.Object.create({workStatus: 
App.Service.statesMap.stopped}), Em.Object.create({workStatus: 
App.Service.statesMap.stopped})]);
       mainServiceItemController.deleteService('S1');
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      expect(mainServiceItemController.showLastWarning.calledOnce).to.be.true;
     });
 
     it("service has not dependent services, and install failed", function() {
@@ -1447,7 +1448,7 @@ describe('App.MainServiceItemController', function () {
       this.allowUninstallServices.returns(true);
       this.mockService.returns([Em.Object.create({workStatus: 
App.Service.statesMap.install_failed}), Em.Object.create({workStatus: 
App.Service.statesMap.install_failed})]);
       mainServiceItemController.deleteService('S1');
-      expect(App.showConfirmationPopup.calledOnce).to.be.true;
+      expect(mainServiceItemController.showLastWarning.calledOnce).to.be.true;
     });
 
     it("service has not dependent services, and not stopped", function() {
@@ -1671,27 +1672,27 @@ describe('App.MainServiceItemController', function () {
 
     beforeEach(function() {
       mainServiceItemController = App.MainServiceItemController.create({});
-      sinon.stub(mainServiceItemController, 'loadConfigRecommendations', Em.K);
+      sinon.stub(mainServiceItemController, 'saveConfigs', Em.K);
       sinon.stub(mainServiceItemController, 'deleteServiceCall', Em.K);
       mainServiceItemController.reopen({
         interDependentServices: []
       })
     });
     afterEach(function() {
-      mainServiceItemController.loadConfigRecommendations.restore();
+      mainServiceItemController.saveConfigs.restore();
       mainServiceItemController.deleteServiceCall.restore();
     });
 
     it("window.location.reload should be called", function() {
       mainServiceItemController.deleteServiceCallSuccessCallback([], null, {});
       expect(mainServiceItemController.deleteServiceCall.called).to.be.false;
-      
expect(mainServiceItemController.loadConfigRecommendations.calledOnce).to.be.true;
+      expect(mainServiceItemController.saveConfigs.calledOnce).to.be.true;
     });
 
     it("deleteServiceCall should be called", function() {
       mainServiceItemController.deleteServiceCallSuccessCallback([], null, 
{servicesToDeleteNext: true});
       
expect(mainServiceItemController.deleteServiceCall.calledOnce).to.be.true;
-      
expect(mainServiceItemController.loadConfigRecommendations.called).to.be.false;
+      expect(mainServiceItemController.saveConfigs.called).to.be.false;
     });
   });
 

Reply via email to