ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nc...@apache.org
Subject [01/11] ambari git commit: AMBARI-14802. Confusing maintenance mode behaviour for host components (akovalenko)
Date Wed, 27 Jan 2016 15:33:20 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-dev-patch-upgrade c7be26ad6 -> e7bdb7b05


AMBARI-14802. Confusing maintenance mode behaviour for host components (akovalenko)


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

Branch: refs/heads/branch-dev-patch-upgrade
Commit: 5403549d9809bb8b9ca5d30e8e46b2d5d22a9762
Parents: 7bac2a1
Author: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Authored: Tue Jan 26 19:24:48 2016 +0200
Committer: Aleksandr Kovalenko <akovalenko@hortonworks.com>
Committed: Tue Jan 26 23:50:18 2016 +0200

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js    |  7 ++++---
 ambari-web/app/messages.js                         |  2 ++
 ambari-web/app/models/host_component.js            |  6 ++++++
 ambari-web/app/styles/application.less             |  3 +++
 .../templates/main/host/details/host_component.hbs |  3 ++-
 ambari-web/app/utils/ember_computed.js             |  2 +-
 .../views/main/host/details/host_component_view.js | 17 +++++++++++++++++
 .../test/controllers/main/host/details_test.js     | 10 ++++++++++
 8 files changed, 45 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index d325cde..251d7ab 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -2307,9 +2307,10 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
   },
 
   toggleMaintenanceMode: function (event) {
-    var self = this;
-    var state = event.context.get('passiveState') === "ON" ? "OFF" : "ON";
-    var message = Em.I18n.t('passiveState.turn' + state.toCapital() + 'For').format(event.context.get('displayName'));
+    var state, message, self = this;
+    if (event.context.get('isImpliedState')) return null;
+    state = event.context.get('passiveState') === "ON" ? "OFF" : "ON";
+    message = Em.I18n.t('passiveState.turn' + state.toCapital() + 'For').format(event.context.get('displayName'));
     return App.showConfirmationPopup(function () {
       self.updateComponentPassiveState(event.context, state, message);
     });

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index a153408..d6ecbf3 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -314,6 +314,8 @@ Em.I18n.translations = {
   'passiveState.turnOff':'Turn Off Maintenance Mode',
   'passiveState.turnOnFor':'Turn On Maintenance Mode for {0}',
   'passiveState.turnOffFor':'Turn Off Maintenance Mode for {0}',
+  'passiveState.disabled.impliedFromHighLevel':'{0} is already in Maintenance Mode because
{1} is in Maintenance Mode.',
+  'passiveState.disabled.impliedFromServiceAndHost':'{0} is already in Maintenance Mode because
{1} and {2} are in Maintenance Mode.',
 
   'requestInfo.installComponents':'Install Components',
   'requestInfo.installKerbeorosComponents':'Install Kerberos Components',

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js
index 5008277..77395f2 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -113,6 +113,12 @@ App.HostComponent = DS.Model.extend({
    */
   isActive: Em.computed.equal('passiveState', 'OFF'),
 
+  /**
+   * Determine if passiveState is implied from host or/and service
+   * @returns {Boolean}
+   */
+  isImpliedState: Em.computed.existsIn('passiveState', ['IMPLIED_FROM_SERVICE_AND_HOST',
'IMPLIED_FROM_HOST', 'IMPLIED_FROM_SERVICE']),
+
   passiveTooltip: Em.computed.ifThenElse('isActive', '', Em.I18n.t('hosts.component.passive.mode')),
   /**
    * Determine if component is a HDP component

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/styles/application.less
----------------------------------------------------------------------
diff --git a/ambari-web/app/styles/application.less b/ambari-web/app/styles/application.less
index 8ebf701..731903d 100644
--- a/ambari-web/app/styles/application.less
+++ b/ambari-web/app/styles/application.less
@@ -3695,6 +3695,9 @@ table.graphs {
         color: #808080;
         cursor: default;
       }
+      .allow-tooltip {
+        pointer-events: auto;
+      }
     }
   }
   .host-tab-content {

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/templates/main/host/details/host_component.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details/host_component.hbs b/ambari-web/app/templates/main/host/details/host_component.hbs
index 4976632..00db8d1 100644
--- a/ambari-web/app/templates/main/host/details/host_component.hbs
+++ b/ambari-web/app/templates/main/host/details/host_component.hbs
@@ -105,7 +105,8 @@
             {{/isAuthorized}}
           {{/if}}
           {{#isAuthorized "HOST.TOGGLE_MAINTENANCE"}}
-            <li {{bindAttr class="view.noActionAvailable"}}>
+            <li {{bindAttr class="view.noActionAvailable view.content.isImpliedState:disabled
:allow-tooltip"}}
+              {{bindAttr data-original-title="view.maintenanceTooltip"}} rel="passiveTooltip"
>
             <a href="javascript:void(null)"
                data-toggle="modal" {{action "toggleMaintenanceMode" view.content target="controller"}}>
               {{#if view.isActive}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/utils/ember_computed.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ember_computed.js b/ambari-web/app/utils/ember_computed.js
index b555a93..e3a2f63 100644
--- a/ambari-web/app/utils/ember_computed.js
+++ b/ambari-web/app/utils/ember_computed.js
@@ -601,7 +601,7 @@ computed.ltProperties = function (dependentKey1, dependentKey2) {
  * <pre>
  * var o = Em.Object.create({
  *  p1: 'abc',
- *  p2: Em.computed.lteProperties('p1', /^a/)
+ *  p2: Em.computed.match('p1', /^a/)
  * });
  * console.log(o.get('p2')); // true
  * o.set('p1', 'bc');

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/app/views/main/host/details/host_component_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_view.js b/ambari-web/app/views/main/host/details/host_component_view.js
index 21295b8..6205604 100644
--- a/ambari-web/app/views/main/host/details/host_component_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_view.js
@@ -153,6 +153,23 @@ App.HostComponentView = Em.View.extend({
   isActive: Em.computed.equal('content.passiveState', 'OFF'),
 
   /**
+   *  Tooltip message for switch maintenance mode option
+   *  @type {Strting}
+   */
+  maintenanceTooltip: function () {
+    switch (this.get('content.passiveState')) {
+      case 'IMPLIED_FROM_SERVICE':
+        return Em.I18n.t('passiveState.disabled.impliedFromHighLevel').format(this.get('content.displayName'),
this.get('content.service.serviceName'));
+      case 'IMPLIED_FROM_HOST':
+        return Em.I18n.t('passiveState.disabled.impliedFromHighLevel').format(this.get('content.displayName'),
this.get('content.host.hostName'));
+      case 'IMPLIED_FROM_SERVICE_AND_HOST':
+        return Em.I18n.t('passiveState.disabled.impliedFromServiceAndHost').format(this.get('content.displayName'),
this.get('content.service.serviceName'), this.get('content.host.hostName'));
+      default:
+        return '';
+    }
+  }.property('content.passiveState'),
+
+  /**
    * Shows whether we need to show Delete button
    * @type {bool}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/5403549d/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 51e649c..9bdd64c 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -2936,6 +2936,16 @@ describe('App.MainHostDetailsController', function () {
         passiveState: 'OFF'
       }), 'ON')).to.be.true;
     });
+    it('isImpliedState is true', function () {
+      var event = {
+        context: Em.Object.create({
+          isImpliedState: true
+        })
+      };
+      var result = controller.toggleMaintenanceMode(event);
+      expect(App.showConfirmationPopup.calledOnce).to.be.false;
+      expect(result).to.be.null;
+    });
   });
 
   describe('#installClients()', function () {


Mime
View raw message