Repository: ambari Updated Branches: refs/heads/trunk c96a9e417 -> 09406ac65
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/09406ac6 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/09406ac6 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/09406ac6 Branch: refs/heads/trunk Commit: 09406ac65f78a5213236ec33735dccd35e61d90b Parents: c96a9e4 Author: Oleksandr Diachenko <[email protected]> Authored: Wed Dec 30 11:41:22 2015 -0800 Committer: Oleksandr Diachenko <[email protected]> Committed: Wed Dec 30 11:41:22 2015 -0800 ---------------------------------------------------------------------- ambari-web/app/messages.js | 2 ++ ambari-web/app/models/host_component.js | 8 ++++- .../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, 36 insertions(+), 29 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/09406ac6/ambari-web/app/messages.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js index 17a9ef9..8892cac 100644 --- a/ambari-web/app/messages.js +++ b/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', http://git-wip-us.apache.org/repos/asf/ambari/blob/09406ac6/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 4fe08f5..b463c80 100644 --- a/ambari-web/app/models/host_component.js +++ b/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', http://git-wip-us.apache.org/repos/asf/ambari/blob/09406ac6/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 7247134..21295b8 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 @@ -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, ["_", "-", " "])); }, /** http://git-wip-us.apache.org/repos/asf/ambari/blob/09406ac6/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 f85f266..1dfa937 100644 --- a/ambari-web/app/views/main/service/item.js +++ b/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() { http://git-wip-us.apache.org/repos/asf/ambari/blob/09406ac6/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 e8366bd..648f0f6 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 @@ -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); }) }); });
