Bläddra i källkod

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

Oleksandr Diachenko 9 år sedan
förälder
incheckning
09406ac65f

+ 2 - 0
ambari-web/app/messages.js

@@ -1660,6 +1660,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',

+ 7 - 1
ambari-web/app/models/host_component.js

@@ -364,7 +364,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',

+ 7 - 7
ambari-web/app/views/main/host/details/host_component_view.js

@@ -294,9 +294,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,
@@ -314,11 +314,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(App.format.normalizeNameBySeparators(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(App.format.normalizeNameBySeparators(command, ["_", "-", " "]));
   },
 
   /**

+ 2 - 1
ambari-web/app/views/main/service/item.js

@@ -35,7 +35,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() {

+ 18 - 20
ambari-web/test/views/main/host/details/host_component_view_test.js

@@ -288,9 +288,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() {
@@ -300,6 +312,7 @@ describe('App.HostComponentView', function() {
 
     after(function() {
       App.StackServiceComponent.find.restore();
+      App.HostComponentActionMap.getMap.restore();
     });
   });
 
@@ -331,40 +344,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);
       })
     });
   });