You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by is...@apache.org on 2018/08/31 18:03:35 UTC

[ambari] branch branch-2.7 updated: [AMBARI-24577] Services should display the Stop button if any of their components are started.

This is an automated email from the ASF dual-hosted git repository.

ishanbha pushed a commit to branch branch-2.7
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/branch-2.7 by this push:
     new be87ee5  [AMBARI-24577] Services should display the Stop button if any of their components are started.
be87ee5 is described below

commit be87ee58c3bbd4f315d65836dc5d996211ba3463
Author: Ishan Bhatt <is...@gmail.com>
AuthorDate: Thu Aug 30 15:34:02 2018 -0700

    [AMBARI-24577] Services should display the Stop button if any of their components are started.
---
 ambari-web/app/controllers/main/service/item.js    |  21 +++-
 .../test/controllers/main/service/item_test.js     | 107 +++++++++++++++++++--
 2 files changed, 119 insertions(+), 9 deletions(-)

diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index 6560666..d52cc3f 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1176,10 +1176,21 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     return App.MasterComponent.find().toArray().concat(App.SlaveComponent.find().toArray()).filterProperty('service.serviceName', this.get('content.serviceName'));
   }.property('content.serviceName'),
 
-  isStartDisabled: Em.computed.or('isPending', 'content.isStarted'),
+  isStartDisabled: function () {
+    let allComponentsStarted = true;
+    if (this.get('isPending')) return true;
+    this.get('nonClientServiceComponents').forEach(function (component) {
+      if (component.get('installedCount') > 0)
+        allComponentsStarted = false;
+    });
+    return allComponentsStarted && this.get('content.isStarted');
+  }.property('content.isStarted', 'isPending'),
+
 
   isStopDisabled: function () {
+    let allComponentsStopped = true;
     if(this.get('isPending')) return true;
+
     if (App.get('isHaEnabled') && this.get('content.serviceName') == 'HDFS' && this.get('content.hostComponents').filterProperty('componentName', 'NAMENODE').someProperty('workStatus', App.HostComponentStatus.started)) {
       return false;
     }
@@ -1189,7 +1200,13 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     if (this.get('content.serviceName') == 'PXF' && App.HostComponent.find().filterProperty('componentName', 'PXF').someProperty('workStatus', App.HostComponentStatus.started)) {
       return false;
     }
-    return !this.get('content.isStarted');
+
+    this.get('nonClientServiceComponents').forEach(function (component) {
+      if (component.get('startedCount') > 0)
+        allComponentsStopped = false;
+    });
+
+    return allComponentsStopped && !this.get('content.isStarted');
   }.property('content.isStarted','isPending', 'App.isHaEnabled'),
 
   isSmokeTestDisabled: function () {
diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js
index 35d31a8..e6abebe 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -53,10 +53,6 @@ var stackServiceModel = {
 
 describe('App.MainServiceItemController', function () {
 
-  App.TestAliases.testAsComputedOr(App.MainServiceItemController.create({
-    content: Em.Object.create({serviceName: 'S1'})
-  }), 'isStartDisabled', ['isPending', 'content.isStarted']);
-
   describe('#setStartStopState', function () {
     var tests = [
       {
@@ -891,12 +887,86 @@ describe('App.MainServiceItemController', function () {
   });
 
 
+  describe("#isStartDisabled", function () {
+    var tests = [
+      {
+        content: {
+          isStarted: true
+        },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            installedCount: 0
+          })
+        ],
+        isPending: false,
+        disabled: true,
+        m: "disabled since service state is started and no component is stopped"
+      },
+      {
+        content: {
+          isStarted: true
+        },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            installedCount: 0
+          }),
+          Em.Object.create({
+            installedCount: 2
+          })
+        ],
+        isPending: false,
+        disabled: false,
+        m: "enabled although service state is started, 2 components are stopped"
+      },
+      {
+        content: {
+          isStarted: false
+        },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            installedCount: 0
+          }),
+          Em.Object.create({
+            installedCount: 0
+          })
+        ],
+        isPending: false,
+        disabled: false,
+        m: "enabled although all components are stopped service state is not started"
+      },
+      {
+        content: {
+          isStarted: true
+        },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            installedCount: 0
+          })
+        ],
+        isPending: true,
+        disabled: true,
+        m: "disabled since state is pending."
+      },
+    ];
+    tests.forEach(function (test) {
+      it(test.m, function () {
+        var mainServiceItemController = App.MainServiceItemController.create({content: test.content, isPending: test.isPending, nonClientServiceComponents: test.nonClientServiceComponents});
+        expect(mainServiceItemController.get('isStartDisabled')).to.equal(test.disabled);
+      });
+    });
+  });
+
   describe("#isStopDisabled", function () {
     var tests = [
       {
         content: {
           isStarted: false
         },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            startedCount: 0
+          })
+        ],
         isPending: true,
         disabled: true,
         m: "disabled because of pending"
@@ -905,22 +975,45 @@ describe('App.MainServiceItemController', function () {
         content: {
           isStarted: true
         },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            startedCount: 0
+          })
+        ],
+        isPending: false,
+        disabled: false,
+        m: "enabled because healthStatus is green although no components are started"
+      },
+      {
+        content: {
+          isStarted: false
+        },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            startedCount: 1
+          })
+        ],
         isPending: false,
         disabled: false,
-        m: "enabled because healthStatus is green and pending is false"
+        m: "enabled because atleast 1 component is started."
       },
       {
         content: {
           isStarted: false
         },
+        nonClientServiceComponents: [
+          Em.Object.create({
+            startedCount: 0
+          })
+        ],
         isPending: false,
         disabled: true,
-        m: "disabled because healthStatus is not green"
+        m: "disabled because healthStatus is not green and no started components"
       }
     ];
     tests.forEach(function (test) {
       it(test.m, function () {
-        var mainServiceItemController = App.MainServiceItemController.create({content: test.content, isPending: test.isPending});
+        var mainServiceItemController = App.MainServiceItemController.create({content: test.content, isPending: test.isPending, nonClientServiceComponents: test.nonClientServiceComponents});
         expect(mainServiceItemController.get('isStopDisabled')).to.equal(test.disabled);
       });
     });