Repository: ambari
Updated Branches:
  refs/heads/branch-2.2 dcde3a4d2 -> b577dffa1


AMBARI-14477. Custom command label for HAWQ Segment Stop (Immediate Mode) 
(mithmatt via odiachenko).


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

Branch: refs/heads/branch-2.2
Commit: b577dffa1b64c174ddcf3bed414886daf641e033
Parents: dcde3a4
Author: Oleksandr Diachenko <[email protected]>
Authored: Wed Dec 30 11:44:31 2015 -0800
Committer: Oleksandr Diachenko <[email protected]>
Committed: Wed Dec 30 11:44:31 2015 -0800

----------------------------------------------------------------------
 ambari-web/app/messages.js                      |  2 ++
 ambari-web/app/models/host_component.js         | 10 ++++--
 .../main/host/details/host_component_view.js    | 14 ++++----
 ambari-web/app/views/main/service/item.js       |  3 +-
 .../host/details/host_component_view_test.js    | 38 ++++++++++----------
 5 files changed, 37 insertions(+), 30 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b577dffa/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index b8257e6..820d3c9 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1671,6 +1671,8 @@ Em.I18n.translations = {
   'services.service.actions.run.stopLdapKnox.context':'Stop Demo LDAP',
   'services.service.actions.run.startStopLdapKnox.error': 'Error during remote 
command: ',
   'services.service.actions.run.immediateStopHawqCluster.context':'Stop HAWQ 
Cluster (Immediate Mode)',
+  'services.service.actions.run.immediateStopHawqSegment.label':'Stop 
(Immediate Mode)',
+  'services.service.actions.run.immediateStopHawqSegment.context':'Stop HAWQ 
Segment (Immediate Mode)',
   'services.service.actions.run.immediateStopHawqCluster.error': 'Error during 
remote command: ',
   'services.service.actions.manage_configuration_groups.short':'Manage Config 
Groups',
   'services.service.actions.serviceActions':'Service Actions',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b577dffa/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 600105b..e61822a 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -363,7 +363,13 @@ App.HostComponentActionMap = {
         context: 
Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
         label: 
Em.I18n.t('services.service.actions.run.immediateStopHawqCluster.context'),
         cssClass: 'icon-stop',
-        disabled: false,
+        disabled: false
+      },
+      IMMEDIATE_STOP: {
+        customCommand: 'IMMEDIATE_STOP',
+        context: 
Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.context'),
+        label: 
Em.I18n.t('services.service.actions.run.immediateStopHawqSegment.label'),
+        cssClass: 'icon-stop'
       },
       MASTER_CUSTOM_COMMAND: {
         action: 'executeCustomCommand',
@@ -373,4 +379,4 @@ App.HostComponentActionMap = {
       }
     }
   }
-};
\ No newline at end of file
+};

http://git-wip-us.apache.org/repos/asf/ambari/blob/b577dffa/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 9605a92..9aabe42 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
@@ -329,9 +329,9 @@ App.HostComponentView = Em.View.extend({
         return;
       }
 
-      var isContextPresent =  (!isSlave && (command in 
App.HostComponentActionMap.getMap(self)) &&  
App.HostComponentActionMap.getMap(self)[command].context);
+      var isContextPresent = command in 
App.HostComponentActionMap.getMap(self) && 
App.HostComponentActionMap.getMap(self)[command].context;
       customCommands.push({
-        label: self.getCustomCommandLabel(command, isSlave),
+        label: self.getCustomCommandLabel(command),
         service: component.get('serviceName'),
         hosts: hostComponent.get('hostName'),
         context: isContextPresent ? 
App.HostComponentActionMap.getMap(self)[command].context : null,
@@ -349,11 +349,11 @@ App.HostComponentView = Em.View.extend({
    * @param command
    * @returns {String}
    */
-  getCustomCommandLabel: function (command, isSlave) {
-    if (isSlave || !(command in App.HostComponentActionMap.getMap(this)) || 
!App.HostComponentActionMap.getMap(this)[command].label) {
-      return 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format(command)
-    }
-    return App.HostComponentActionMap.getMap(this)[command].label;
+  getCustomCommandLabel: function (command) {
+    if (command in App.HostComponentActionMap.getMap(this) && 
App.HostComponentActionMap.getMap(this)[command].label)
+      return App.HostComponentActionMap.getMap(this)[command].label;
+
+    return 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format(command);
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/b577dffa/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js 
b/ambari-web/app/views/main/service/item.js
index 94977cd..275c5ec 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -42,7 +42,8 @@ App.MainServiceItemView = Em.View.extend({
     'RESOURCEMANAGER': ['DECOMMISSION', 'REFRESHQUEUES'],
     'HBASE_MASTER': ['DECOMMISSION'],
     'KNOX_GATEWAY': ['STARTDEMOLDAP','STOPDEMOLDAP'],
-    'HAWQMASTER': ['IMMEDIATE_STOP_CLUSTER']
+    'HAWQMASTER': ['IMMEDIATE_STOP_CLUSTER'],
+    'HAWQSEGMENT': ['IMMEDIATE_STOP']
   },
 
    addActionMap: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/b577dffa/ambari-web/test/views/main/host/details/host_component_view_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/views/main/host/details/host_component_view_test.js 
b/ambari-web/test/views/main/host/details/host_component_view_test.js
index bbcc897..12f9169 100644
--- a/ambari-web/test/views/main/host/details/host_component_view_test.js
+++ b/ambari-web/test/views/main/host/details/host_component_view_test.js
@@ -437,9 +437,21 @@ describe('App.HostComponentView', function() {
         return Em.Object.create({
           componentName: 'SLAVE_COMPONENT',
           isSlave: true,
-          customCommands: ['CUSTOM']
+          customCommands: ['SLAVE_CUSTOM_COMMAND']
         });
       });
+      sinon.stub(App.HostComponentActionMap, 'getMap', function () {
+        return {
+          SLAVE_CUSTOM_COMMAND: {
+            customCommand: 'SLAVE_CUSTOM_COMMAND',
+            cssClass: 'icon-play-circle',
+            label: 'Custom Command',
+            context: 'Custom Command',
+            isHidden: false,
+            disabled: false
+          }
+        }
+      });
     });
 
     it('Should get custom commands for slaves', function() {
@@ -449,6 +461,7 @@ describe('App.HostComponentView', function() {
 
     after(function() {
       App.StackServiceComponent.find.restore();
+      App.HostComponentActionMap.getMap.restore();
     });
   });
 
@@ -600,40 +613,25 @@ describe('App.HostComponentView', function() {
 
     var tests = Em.A([
       {
-        msg: 'Non-slave component not present in 
`App.HostComponentActionMap.getMap()` should have a default valid label',
-        isSlave: false,
+        msg: 'Component not present in `App.HostComponentActionMap.getMap()` 
should have a default valid label',
         command: 'CUSTOM',
         e: 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format('CUSTOM')
       },
       {
-        msg: 'Non-slave component present in 
`App.HostComponentActionMap.getMap()` with no label should have a default valid 
label',
-        isSlave: false,
+        msg: 'Component present in `App.HostComponentActionMap.getMap()` with 
no label should have a default valid label',
         command: 'MASTER_CUSTOM_COMMAND',
         e: 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format('MASTER_CUSTOM_COMMAND')
       },
       {
-        msg: 'Non-slave component present in 
`App.HostComponentActionMap.getMap()` with label should have a custom valid 
label',
-        isSlave: false,
+        msg: 'Component present in `App.HostComponentActionMap.getMap()` with 
label should have a custom valid label',
         command: 'REFRESHQUEUES',
         e: Em.I18n.t('services.service.actions.run.yarnRefreshQueues.menu')
-      },
-      {
-        msg: 'Slave component not present in 
`App.HostComponentActionMap.getMap()` should have a default valid label',
-        isSlave: true,
-        command: 'CUSTOM',
-        e: 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format('CUSTOM')
-      },
-      {
-        msg: 'Slave component present in `App.HostComponentActionMap.getMap()` 
should have a default valid label',
-        isSlave: true,
-        command: 'REFRESHQUEUES',
-        e: 
Em.I18n.t('services.service.actions.run.executeCustomCommand.menu').format('REFRESHQUEUES')
       }
     ]);
 
     tests.forEach(function(test) {
       it(test.msg, function() {
-        expect(hostComponentView.getCustomCommandLabel(test.command, 
test.isSlave)).to.equal(test.e);
+        
expect(hostComponentView.getCustomCommandLabel(test.command)).to.equal(test.e);
       })
     });
   });

Reply via email to