Переглянути джерело

AMBARI-16900 Delete Host message is incorrect, suggests all Clients will be deleted from cluster. (atkach)

Andrii Tkach 9 роки тому
батько
коміт
bcf0d75d54

+ 2 - 4
ambari-web/app/controllers/main/host/details.js

@@ -2067,7 +2067,6 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
    */
   getHostComponentsInfo: function () {
     var componentsOnHost = this.get('content.hostComponents');
-    var allComponents = App.HostComponent.find();
     var stoppedStates = [App.HostComponentStatus.stopped,
       App.HostComponentStatus.install_failed,
       App.HostComponentStatus.upgrade_failed,
@@ -2082,13 +2081,12 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
       unknownComponents: [],
       toDecommissionComponents: []
     };
-    var self = this;
     if (componentsOnHost && componentsOnHost.get('length') > 0) {
       componentsOnHost.forEach(function (cInstance) {
         if (cInstance.get('componentName') === 'ZOOKEEPER_SERVER') {
           container.zkServerInstalled = true;
         }
-        if (allComponents.filterProperty('componentName', cInstance.get('componentName')).get('length') === 1) {
+        if (this.getTotalComponent(cInstance) === 1) {
           container.lastComponents.push(cInstance.get('displayName'));
         }
         var workStatus = cInstance.get('workStatus');
@@ -2107,7 +2105,7 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
         if (App.get('components.decommissionAllowed').contains(cInstance.get('componentName')) && !cInstance.get('view.isComponentRecommissionAvailable')) {
           container.toDecommissionComponents.push(cInstance.get('displayName'));
         }
-      });
+      }, this);
     }
     return container;
   },

+ 4 - 0
ambari-web/test/controllers/main/host/details_test.js

@@ -1998,10 +1998,13 @@ describe('App.MainHostDetailsController', function () {
         id: 'TASKTRACKER_host1',
         componentName: 'TASKTRACKER'
       }]);
+      this.mockTotal = sinon.stub(controller, 'getTotalComponent');
+      this.mockTotal.returns(2);
     });
 
     afterEach(function () {
       this.stub.restore();
+      this.mockTotal.restore();
     });
 
     it('content.hostComponents is null', function () {
@@ -2035,6 +2038,7 @@ describe('App.MainHostDetailsController', function () {
           isDeletable: true
         })]
       });
+      this.mockTotal.returns(1);
       expect(controller.getHostComponentsInfo().lastComponents).to.eql(['TaskTracker']);
     });