Browse Source

AMBARI-5082 Host Details: Hide "Turn On|Off Maintenance Mode" action for components; Hosts > Bulk Ops > Slaves: Hide "Turn On|Off Maintenance Mode". (ababiichuk)

aBabiichuk 11 years ago
parent
commit
69dafbc93c

+ 3 - 61
ambari-web/app/controllers/main/host.js

@@ -148,16 +148,11 @@ App.MainHostController = Em.ArrayController.extend({
         this.bulkOperationForHostComponentsRestart(operationData, hosts);
         this.bulkOperationForHostComponentsRestart(operationData, hosts);
       }
       }
       else {
       else {
-        if (operationData.action === 'PASSIVE_STATE') {
-          this.bulkOperationForHostComponentsPassiveState(operationData, hosts);
+        if (operationData.action.indexOf('DECOMMISSION') != -1) {
+          this.bulkOperationForHostComponentsDecommission(operationData, hosts);
         }
         }
         else {
         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) {
   updateHostComponentsPassiveState: function(data, opt, params) {
     App.router.get('clusterController').loadUpdatedStatus(function(){
     App.router.get('clusterController').loadUpdatedStatus(function(){
       batchUtils.infoPassiveState(params.passive_state);
       batchUtils.infoPassiveState(params.passive_state);

+ 0 - 41
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
    * Restart clients host components to apply config changes
    */
    */

+ 0 - 15
ambari-web/app/templates/main/host/details/host_component.hbs

@@ -105,21 +105,6 @@
               </a>
               </a>
             </li>
             </li>
           {{/if}}
           {{/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}}
         {{/unless}}
         {{#if view.isInit}}
         {{#if view.isInit}}
           <li {{bindAttr class="view."}}>
           <li {{bindAttr class="view."}}>

+ 0 - 20
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;
     return menuItems;
   },
   },
 
 

+ 0 - 121
ambari-web/test/controllers/main/host_test.js

@@ -36,7 +36,6 @@ describe('MainHostController', function () {
         bulkOperationForHostComponentsRestart: function(){},
         bulkOperationForHostComponentsRestart: function(){},
         bulkOperationForHostComponentsDecommission: function(){},
         bulkOperationForHostComponentsDecommission: function(){},
         bulkOperationForHostComponents: function(){},
         bulkOperationForHostComponents: function(){},
-        bulkOperationForHostComponentsPassiveState: function(){},
         bulkOperationForHostsPassiveState: function(){}
         bulkOperationForHostsPassiveState: function(){}
       });
       });
       sinon.spy(hostController, 'bulkOperationForHostsRestart');
       sinon.spy(hostController, 'bulkOperationForHostsRestart');
@@ -44,7 +43,6 @@ describe('MainHostController', function () {
       sinon.spy(hostController, 'bulkOperationForHostComponentsRestart');
       sinon.spy(hostController, 'bulkOperationForHostComponentsRestart');
       sinon.spy(hostController, 'bulkOperationForHostComponentsDecommission');
       sinon.spy(hostController, 'bulkOperationForHostComponentsDecommission');
       sinon.spy(hostController, 'bulkOperationForHostComponents');
       sinon.spy(hostController, 'bulkOperationForHostComponents');
-      sinon.spy(hostController, 'bulkOperationForHostComponentsPassiveState');
       sinon.spy(hostController, 'bulkOperationForHostsPassiveState');
       sinon.spy(hostController, 'bulkOperationForHostsPassiveState');
     });
     });
 
 
@@ -54,7 +52,6 @@ describe('MainHostController', function () {
       hostController.bulkOperationForHostComponentsRestart.restore();
       hostController.bulkOperationForHostComponentsRestart.restore();
       hostController.bulkOperationForHostComponentsDecommission.restore();
       hostController.bulkOperationForHostComponentsDecommission.restore();
       hostController.bulkOperationForHostComponents.restore();
       hostController.bulkOperationForHostComponents.restore();
-      hostController.bulkOperationForHostComponentsPassiveState.restore();
       hostController.bulkOperationForHostsPassiveState.restore();
       hostController.bulkOperationForHostsPassiveState.restore();
 
 
     });
     });
@@ -136,15 +133,6 @@ describe('MainHostController', function () {
       expect(hostController.bulkOperationForHostComponentsDecommission.calledOnce).to.equal(true);
       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() {
   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)
-      });
-    });
-
-  });
-
 });
 });