Repository: ambari Updated Branches: refs/heads/trunk 148cf0ac9 -> 69dafbc93
AMBARI-5082 Host Details: Hide "Turn On|Off Maintenance Mode" action for components; Hosts > Bulk Ops > Slaves: Hide "Turn On|Off Maintenance Mode". (ababiichuk) Project: http://git-wip-us.apache.org/repos/asf/ambari/repo Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/69dafbc9 Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/69dafbc9 Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/69dafbc9 Branch: refs/heads/trunk Commit: 69dafbc93cfc66247ba37754898d2cbe3d6c1cf9 Parents: 148cf0a Author: aBabiichuk <[email protected]> Authored: Fri Mar 14 13:55:37 2014 +0200 Committer: aBabiichuk <[email protected]> Committed: Fri Mar 14 13:55:37 2014 +0200 ---------------------------------------------------------------------- ambari-web/app/controllers/main/host.js | 64 +--------- ambari-web/app/controllers/main/host/details.js | 41 ------- .../main/host/details/host_component.hbs | 15 --- .../views/main/host/hosts_table_menu_view.js | 20 --- ambari-web/test/controllers/main/host_test.js | 121 ------------------- 5 files changed, 3 insertions(+), 258 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/ambari/blob/69dafbc9/ambari-web/app/controllers/main/host.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js index 240a98a..57f7859 100644 --- a/ambari-web/app/controllers/main/host.js +++ b/ambari-web/app/controllers/main/host.js @@ -148,16 +148,11 @@ App.MainHostController = Em.ArrayController.extend({ this.bulkOperationForHostComponentsRestart(operationData, hosts); } else { - if (operationData.action === 'PASSIVE_STATE') { - this.bulkOperationForHostComponentsPassiveState(operationData, hosts); + if (operationData.action.indexOf('DECOMMISSION') != -1) { + this.bulkOperationForHostComponentsDecommission(operationData, hosts); } else { - if (operationData.action.indexOf('DECOMMISSION') != -1) { - this.bulkOperationForHostComponentsDecommission(operationData, hosts); - } - else { - this.bulkOperationForHostComponents(operationData, hosts); - } + this.bulkOperationForHostComponents(operationData, hosts); } } } @@ -410,59 +405,6 @@ App.MainHostController = Em.ArrayController.extend({ } }, - /** - * Bulk turn on/off passive state for selected hostComponents - * @param {Object} operationData - * @param {Array} hosts - */ - bulkOperationForHostComponentsPassiveState: function(operationData, hosts) { - var affectedHosts = []; - hosts.forEach(function(host) { - host.get('hostComponents').forEach(function(hostComponent) { - if (hostComponent.get('componentName') == operationData.componentName) { - if (hostComponent.get('passiveState') !== operationData.state) { - if (hostComponent.get('passiveState') === 'IMPLIED') { - if (operationData.state === 'OFF') { - affectedHosts.push(host.get('hostName')); - } - } - else { - if (hostComponent.get('passiveState') === 'ON') { - if (operationData.state === 'OFF') { - affectedHosts.push(host.get('hostName')); - } - } - else { - if (operationData.state === 'ON') { - affectedHosts.push(host.get('hostName')); - } - } - } - } - } - }); - }); - if (affectedHosts.length) { - App.ajax.send({ - name: 'bulk_request.hosts.all_components.passive_state', - sender: this, - data: { - query: 'HostRoles/component_name=' + operationData.componentName + '&HostRoles/host_name.in(' + affectedHosts.join(',') + ')', - passive_state: operationData.state, - requestInfo: operationData.message - }, - success: 'updateHostComponentsPassiveState' - }); - } - else { - App.ModalPopup.show({ - header: Em.I18n.t('rolling.nothingToDo.header'), - body: Em.I18n.t('hosts.bulkOperation.host_components.passiveState.nothingToDo.body'), - secondary: false - }); - } - }, - updateHostComponentsPassiveState: function(data, opt, params) { App.router.get('clusterController').loadUpdatedStatus(function(){ batchUtils.infoPassiveState(params.passive_state); http://git-wip-us.apache.org/repos/asf/ambari/blob/69dafbc9/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 870a9f6..631a770 100644 --- a/ambari-web/app/controllers/main/host/details.js +++ b/ambari-web/app/controllers/main/host/details.js @@ -1245,47 +1245,6 @@ App.MainHostDetailsController = Em.Controller.extend({ }); }, - turnOnOffPassiveConfirmation: function(event){ - var self = this; - var component = event.context; - var state, onOff, message; - if (component.get("passiveState") == "ON") { - onOff = "Off"; - state = "OFF"; - message = Em.I18n.t('passiveState.turnOffFor').format(component.get('displayName')); - } else { - onOff = "On"; - state = "ON"; - message = Em.I18n.t('passiveState.turnOnFor').format(component.get('displayName')); - } - App.showConfirmationPopup(function() { - self.turnOnOffPassive(state, component, message) - }, - Em.I18n.t('hosts.passiveMode.popup').format(onOff,component.get('displayName')) - ); - }, - - turnOnOffPassive: function(state,component,message) { - var hostName = this.get('content.hostName'); - App.ajax.send({ - name: 'host_component.passive', - sender: this, - data: { - component: component, - hostName: hostName, - componentName: component.get('componentName'), - passive_state: state, - requestInfo: message - }, - success: 'updateComponentPassiveState' - }); - }, - - updateComponentPassiveState: function(data, opt, params) { - params.component.set('passiveState',params.passive_state); - batchUtils.infoPassiveState(params.passive_state); - }, - /** * Restart clients host components to apply config changes */ http://git-wip-us.apache.org/repos/asf/ambari/blob/69dafbc9/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 2e54629..352b2c0 100644 --- a/ambari-web/app/templates/main/host/details/host_component.hbs +++ b/ambari-web/app/templates/main/host/details/host_component.hbs @@ -105,21 +105,6 @@ </a> </li> {{/if}} - {{#if view.isActive}} - {{#unless view.isInit}} - <li rel='passiveTooltip' {{bindAttr class="view.noActionAvailable" title="view.passiveImpliedTextStatus"}}> - <a href="javascript:void(null)" {{bindAttr class="view.isImplied:disabled"}} data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> - {{t passiveState.turnOn}} - </a> - </li> - {{/unless}} - {{else}} - <li rel='passiveTooltip' {{bindAttr class="view.noActionAvailable" title="view.passiveImpliedTextStatus"}}> - <a href="javascript:void(null)" {{bindAttr class="view.isImplied:disabled"}} data-toggle="modal" {{action "turnOnOffPassiveConfirmation" view.content target="controller"}}> - {{t passiveState.turnOff}} - </a> - </li> - {{/if}} {{/unless}} {{#if view.isInit}} <li {{bindAttr class="view."}}> http://git-wip-us.apache.org/repos/asf/ambari/blob/69dafbc9/ambari-web/app/views/main/host/hosts_table_menu_view.js ---------------------------------------------------------------------- diff --git a/ambari-web/app/views/main/host/hosts_table_menu_view.js b/ambari-web/app/views/main/host/hosts_table_menu_view.js index 7e185fe..c0638bf 100644 --- a/ambari-web/app/views/main/host/hosts_table_menu_view.js +++ b/ambari-web/app/views/main/host/hosts_table_menu_view.js @@ -87,26 +87,6 @@ App.HostTableMenuView = Em.View.extend({ }) })); } - menuItems.pushObjects(Em.A([ - Em.Object.create({ - label: Em.I18n.t('passiveState.turnOn'), - operationData: Em.Object.create({ - state: 'ON', - action: 'PASSIVE_STATE', - message: Em.I18n.t('passiveState.turnOnFor').format(App.format.components[componentNameForOtherActions]), - componentName: componentNameForOtherActions - }) - }), - Em.Object.create({ - label: Em.I18n.t('passiveState.turnOff'), - operationData: Em.Object.create({ - state: 'OFF', - action: 'PASSIVE_STATE', - message: Em.I18n.t('passiveState.turnOffFor').format(App.format.components[componentNameForOtherActions]), - componentName: componentNameForOtherActions - }) - }) - ])); return menuItems; }, http://git-wip-us.apache.org/repos/asf/ambari/blob/69dafbc9/ambari-web/test/controllers/main/host_test.js ---------------------------------------------------------------------- diff --git a/ambari-web/test/controllers/main/host_test.js b/ambari-web/test/controllers/main/host_test.js index 97294a6..ebff80b 100644 --- a/ambari-web/test/controllers/main/host_test.js +++ b/ambari-web/test/controllers/main/host_test.js @@ -36,7 +36,6 @@ describe('MainHostController', function () { bulkOperationForHostComponentsRestart: function(){}, bulkOperationForHostComponentsDecommission: function(){}, bulkOperationForHostComponents: function(){}, - bulkOperationForHostComponentsPassiveState: function(){}, bulkOperationForHostsPassiveState: function(){} }); sinon.spy(hostController, 'bulkOperationForHostsRestart'); @@ -44,7 +43,6 @@ describe('MainHostController', function () { sinon.spy(hostController, 'bulkOperationForHostComponentsRestart'); sinon.spy(hostController, 'bulkOperationForHostComponentsDecommission'); sinon.spy(hostController, 'bulkOperationForHostComponents'); - sinon.spy(hostController, 'bulkOperationForHostComponentsPassiveState'); sinon.spy(hostController, 'bulkOperationForHostsPassiveState'); }); @@ -54,7 +52,6 @@ describe('MainHostController', function () { hostController.bulkOperationForHostComponentsRestart.restore(); hostController.bulkOperationForHostComponentsDecommission.restore(); hostController.bulkOperationForHostComponents.restore(); - hostController.bulkOperationForHostComponentsPassiveState.restore(); hostController.bulkOperationForHostsPassiveState.restore(); }); @@ -136,15 +133,6 @@ describe('MainHostController', function () { expect(hostController.bulkOperationForHostComponentsDecommission.calledOnce).to.equal(true); }); - it('PASSIVE_STATE for hostComponents', function() { - var operationData = { - action: 'PASSIVE_STATE', - componentNameFormatted: 'DataNodes' - }; - hostController.bulkOperation(operationData, []); - expect(hostController.bulkOperationForHostComponentsPassiveState.calledOnce).to.equal(true); - }); - }); describe('#bulkOperationForHosts', function() { @@ -311,113 +299,4 @@ describe('MainHostController', function () { }); - describe('#bulkOperationForHostComponentsPassiveState', function() { - - beforeEach(function(){ - hostController = App.MainHostController.create({}); - sinon.spy($, 'ajax'); - }); - - afterEach(function() { - $.ajax.restore(); - }); - - var tests = [ - { - hosts: Em.A([]), - operationData: {}, - m: 'No hosts', - e: false - }, - { - hosts: Em.A([ - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }), - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }) - ]), - operationData: { - componentName: 'CN', - state: 'OFF' - }, - m: 'Two hosts with components in state that they should get', - e: false - }, - { - hosts: Em.A([ - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }), - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'ON'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }) - ]), - operationData: { - componentName: 'CN', - state: 'ON' - }, - m: 'One host with component in proper state (OFF)', - e: true - }, - { - hosts: Em.A([ - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }), - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'ON'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }) - ]), - operationData: { - componentName: 'CN', - state: 'ON' - }, - m: 'One host with component in proper state (ON)', - e: true - }, - { - hosts: Em.A([ - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }), - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'IMPLIED'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }) - ]), - operationData: { - componentName: 'CN', - state: 'ON' - }, - m: 'One host with component in proper state (OFF)', - e: true - }, - { - hosts: Em.A([ - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'OFF'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }), - Em.Object.create({ - hostComponents: Em.A([Em.Object.create({componentName:'CN',passiveState:'IMPLIED'}), Em.Object.create({componentName:'ACN',passiveState:'OFF'})]) - }) - ]), - operationData: { - componentName: 'CN', - state: 'OFF' - }, - m: 'One host with component in proper state (ON)', - e: true - } - ]; - - tests.forEach(function(test) { - it(test.m, function() { - hostController.bulkOperationForHostComponentsPassiveState(test.operationData, test.hosts); - expect($.ajax.calledOnce).to.equal(test.e) - }); - }); - - }); - }); \ No newline at end of file
