ソースを参照

AMBARI-18200. Add Service button is not disabled if all services are installed (akovalenko)

Aleksandr Kovalenko 8 年 前
コミット
8b1ec08a36

+ 6 - 2
ambari-web/app/controllers/main/service.js

@@ -51,8 +51,12 @@ App.MainServiceController = Em.ArrayController.extend({
    */
   isAllServicesInstalled: function () {
     if (!this.get('content')) return false;
-    var availableServices = App.StackService.find().mapProperty('serviceName');
-    return this.get('content').length == availableServices.length;
+    var notAvailableServices = App.ServiceSimple.find().filterProperty('doNotShowAndInstall').mapProperty('name');
+    var availableServices = App.ServiceSimple.find().filterProperty('doNotShowAndInstall', false);
+    var installedServices = this.get('content').filter(function (service) {
+      return !notAvailableServices.contains(service.get('serviceName'));
+    });
+    return installedServices.length == availableServices.length;
   }.property('content.@each', 'content.length'),
 
   /**

+ 0 - 4
ambari-web/app/styles/application.less

@@ -2459,10 +2459,6 @@ a:focus {
 
   }
 
-  .add-service-button {
-    margin: 20px 20px 10px;
-  }
-
   .start-stop-all-service-button {
     margin: 5px 5px 10px 10px;
     text-align: center;

+ 1 - 1
ambari-web/app/templates/main/service/all_services_actions.hbs

@@ -24,7 +24,7 @@
             </a>
             <ul class="pull-left dropdown-menu">
                 {{#isAuthorized "SERVICE.ADD_DELETE_SERVICES"}}
-                    <li {{bindAttr class="view.serviceController.isAllServicesInstalled:disabled"}}>
+                    <li {{bindAttr class="view.serviceController.isAllServicesInstalled:disabled :add-service-button"}}>
                         <a href="#"
                             {{bindAttr class="view.serviceController.isAllServicesInstalled:disabled"}}
                             {{action gotoAddService target="view.serviceController"}}>

+ 20 - 4
ambari-web/test/controllers/main/service_test.js

@@ -116,18 +116,17 @@ describe('App.MainServiceController', function () {
   describe("#isAllServicesInstalled", function() {
 
     beforeEach(function() {
-      sinon.stub(App.StackService, 'find').returns([
-        Em.Object.create({serviceName: 'S1'})
-      ]);
+      this.mock = sinon.stub(App.ServiceSimple, 'find');
     });
     afterEach(function() {
-      App.StackService.find.restore();
+      App.ServiceSimple.find.restore();
     });
 
     it("content is null", function() {
       mainServiceController.reopen({
         'content': null
       });
+      this.mock.returns([]);
       mainServiceController.propertyDidChange('isAllServicesInstalled');
       expect(mainServiceController.get('isAllServicesInstalled')).to.be.false;
     });
@@ -136,6 +135,9 @@ describe('App.MainServiceController', function () {
       mainServiceController.reopen({
         'content': []
       });
+      this.mock.returns([
+        {serviceName: 'S1', doNotShowAndInstall: false}
+      ]);
       mainServiceController.propertyDidChange('isAllServicesInstalled');
       expect(mainServiceController.get('isAllServicesInstalled')).to.be.false;
     });
@@ -144,9 +146,23 @@ describe('App.MainServiceController', function () {
       mainServiceController.reopen({
         'content': [Em.Object.create({serviceName: 'S1'})]
       });
+      this.mock.returns([
+        {serviceName: 'S1', doNotShowAndInstall: false}
+      ]);
       mainServiceController.propertyDidChange('isAllServicesInstalled');
       expect(mainServiceController.get('isAllServicesInstalled')).to.be.true;
     });
+    it("content doesn't match stack services", function() {
+      mainServiceController.reopen({
+        'content': [Em.Object.create({serviceName: 'S1'})]
+      });
+      this.mock.returns([
+        {serviceName: 'S1', doNotShowAndInstall: false},
+        {serviceName: 'S1', doNotShowAndInstall: false}
+      ]);
+      mainServiceController.propertyDidChange('isAllServicesInstalled');
+      expect(mainServiceController.get('isAllServicesInstalled')).to.be.false;
+    });
   });
 
   describe('#cluster', function() {