Browse Source

AMBARI-9446. Components Requiring Restart window shows incorrect data. (akovalenko)

Aleksandr Kovalenko 10 năm trước cách đây
mục cha
commit
58523e14a1

+ 3 - 5
ambari-web/app/controllers/main/service/info/configs.js

@@ -2403,8 +2403,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    */
   showHostsShouldBeRestarted: function (restartRequiredHostsAndComponents) {
     var hosts = [];
-    var rhc = this.get('content.restartRequiredHostsAndComponents') || restartRequiredHostsAndComponents;
-    for (var hostName in rhc) {
+    for (var hostName in restartRequiredHostsAndComponents) {
       hosts.push(hostName);
     }
     var hostsText = hosts.length == 1 ? Em.I18n.t('common.host') : Em.I18n.t('common.hosts');
@@ -2417,11 +2416,10 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.ServerValidatorM
    * @method showComponentsShouldBeRestarted
    */
   showComponentsShouldBeRestarted: function (restartRequiredHostsAndComponents) {
-    var rhc = this.get('content.restartRequiredHostsAndComponents') || restartRequiredHostsAndComponents;
     var hostsComponets = [];
     var componentsObject = {};
-    for (var hostName in rhc) {
-      rhc[hostName].forEach(function (hostComponent) {
+    for (var hostName in restartRequiredHostsAndComponents) {
+      restartRequiredHostsAndComponents[hostName].forEach(function (hostComponent) {
         hostsComponets.push(hostComponent);
         if (componentsObject[hostComponent] != undefined) {
           componentsObject[hostComponent]++;

+ 2 - 2
ambari-web/app/templates/main/service/info/configs.hbs

@@ -23,8 +23,8 @@
         <div>
           <div class="alert alert-warning clearfix">
             <i class="icon-refresh"></i> {{t services.service.config.restartService.needToRestart}}  <a
-                  href="#" {{action showComponentsShouldBeRestarted target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}}
-            <a href="#" {{action showHostsShouldBeRestarted target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
+                  href="#" {{action "showComponentsShouldBeRestarted" controller.content.restartRequiredHostsAndComponents target="controller"}}>{{view.componentsCount}} {{pluralize view.componentsCount singular="t:common.component" plural="t:common.components"}}</a> {{t on}}
+            <a href="#" {{action "showHostsShouldBeRestarted" controller.content.restartRequiredHostsAndComponents target="controller"}}>{{view.hostsCount}} {{pluralize view.hostsCount singular="t:common.host" plural="t:common.hosts"}}</a>
             <span class="restart-components pull-right">&nbsp</span>
 
             <div class="btn-group pull-right">

+ 2 - 8
ambari-web/test/controllers/main/service/info/config_test.js

@@ -211,17 +211,14 @@ describe("App.MainServiceInfoConfigsController", function () {
 
     beforeEach(function () {
       sinon.stub(mainServiceInfoConfigsController, "showItemsShouldBeRestarted", Em.K);
-      mainServiceInfoConfigsController.set("content", {restartRequiredHostsAndComponents: ""});
     });
     afterEach(function () {
       mainServiceInfoConfigsController.showItemsShouldBeRestarted.restore();
-      mainServiceInfoConfigsController.set("content", undefined);
     });
 
     tests.forEach(function (t) {
       it("trigger showItemsShouldBeRestarted popup with components", function () {
-        mainServiceInfoConfigsController.set("content.restartRequiredHostsAndComponents", t.input);
-        mainServiceInfoConfigsController.showComponentsShouldBeRestarted();
+        mainServiceInfoConfigsController.showComponentsShouldBeRestarted(t.input);
         expect(mainServiceInfoConfigsController.showItemsShouldBeRestarted.calledWith(t.components, t.text)).to.equal(true);
       });
     });
@@ -249,17 +246,14 @@ describe("App.MainServiceInfoConfigsController", function () {
 
     beforeEach(function () {
       sinon.stub(mainServiceInfoConfigsController, "showItemsShouldBeRestarted", Em.K);
-      mainServiceInfoConfigsController.set("content", {restartRequiredHostsAndComponents: ""});
     });
     afterEach(function () {
       mainServiceInfoConfigsController.showItemsShouldBeRestarted.restore();
-      mainServiceInfoConfigsController.set("content", undefined);
     });
 
     tests.forEach(function (t) {
       it("trigger showItemsShouldBeRestarted popup with hosts", function () {
-        mainServiceInfoConfigsController.set("content.restartRequiredHostsAndComponents", t.input);
-        mainServiceInfoConfigsController.showHostsShouldBeRestarted();
+        mainServiceInfoConfigsController.showHostsShouldBeRestarted(t.input);
         expect(mainServiceInfoConfigsController.showItemsShouldBeRestarted.calledWith(t.hosts, t.text)).to.equal(true);
       });
     });