You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2015/09/03 23:50:00 UTC
ambari git commit: AMBARI-12771. Adding a CustomCommands causes
Components are not being displayed in Host view. (Shantanu Mundkur and Jaimin
Jetly)
Repository: ambari
Updated Branches:
refs/heads/branch-2.1 1dab4b6e8 -> 842e221a6
AMBARI-12771. Adding a CustomCommands causes Components are not being displayed in Host view. (Shantanu Mundkur and Jaimin Jetly)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/842e221a
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/842e221a
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/842e221a
Branch: refs/heads/branch-2.1
Commit: 842e221a62469cd87de4bb4501638fba640ad9cd
Parents: 1dab4b6
Author: Jaimin Jetly <ja...@hortonworks.com>
Authored: Thu Sep 3 14:49:13 2015 -0700
Committer: Jaimin Jetly <ja...@hortonworks.com>
Committed: Thu Sep 3 14:49:56 2015 -0700
----------------------------------------------------------------------
.../main/host/details/host_component_view.js | 6 +-
.../host/details/host_component_view_test.js | 66 ++++++++++++++++++++
2 files changed, 70 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/842e221a/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 2665c35..dec1e86 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
@@ -345,11 +345,13 @@ App.HostComponentView = Em.View.extend({
if (!isSlave && !self.meetsCustomCommandReq(component, command)) {
return;
}
+
+ var isContextPresent = (!isSlave && (command in App.HostComponentActionMap.getMap(self)) && App.HostComponentActionMap.getMap(self)[command].context);
customCommands.push({
label: self.getCustomCommandLabel(command, isSlave),
service: component.get('serviceName'),
hosts: hostComponent.get('hostName'),
- context: isSlave ? null : App.HostComponentActionMap.getMap(self)[command].context,
+ context: isContextPresent ? App.HostComponentActionMap.getMap(self)[command].context : null,
component: component.get('componentName'),
command: command
});
@@ -365,7 +367,7 @@ App.HostComponentView = Em.View.extend({
* @returns {String}
*/
getCustomCommandLabel: function (command, isSlave) {
- if (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;
http://git-wip-us.apache.org/repos/asf/ambari/blob/842e221a/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 2ddc5e4..6f765de 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
@@ -588,4 +588,70 @@ describe('App.HostComponentView', function() {
hostComponentView.runningComponentCounter.restore();
});
});
+
+ describe('#getCustomCommandLabel', function() {
+
+ beforeEach(function () {
+ sinon.stub(App.HostComponentActionMap, 'getMap', function () {
+ return {
+ MASTER_CUSTOM_COMMAND: {
+ action: 'executeCustomCommand',
+ cssClass: 'icon-play-circle',
+ isHidden: false,
+ disabled: false
+ },
+ REFRESHQUEUES: {
+ action: 'refreshYarnQueues',
+ customCommand: 'REFRESHQUEUES',
+ context : Em.I18n.t('services.service.actions.run.yarnRefreshQueues.context'),
+ label: Em.I18n.t('services.service.actions.run.yarnRefreshQueues.menu'),
+ cssClass: 'icon-refresh',
+ disabled: false
+ }
+ }
+ });
+ });
+ afterEach(function() {
+ App.HostComponentActionMap.getMap.restore();
+ });
+
+ var tests = Em.A([
+ {
+ msg: 'Non-slave component not present in `App.HostComponentActionMap.getMap()` should have a default valid label',
+ isSlave: false,
+ 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,
+ 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,
+ 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);
+ })
+ });
+ });
});