Browse Source

AMBARI-14273 Disable 'Restart All Required' button on Dashboard page if there are no stale configs (akovalenko)

Aleksandr Kovalenko 9 years ago
parent
commit
6732e718fd

+ 0 - 31
ambari-web/app/controllers/main.js

@@ -118,37 +118,6 @@ App.MainController = Em.Controller.extend({
     );
   }.observes("App.router.location.lastSetURL", "App.clusterStatus.isInstalled"),
 
-  scRequest: function(request) {
-    return App.router.get('mainServiceController').get(request);
-  },
-
-  isAllServicesInstalled: function() {
-    return this.scRequest('isAllServicesInstalled');
-  }.property('App.router.mainServiceController.content.content.@each',
-  'App.router.mainServiceController.content.content.length'),
-
-  isStartAllDisabled: function() {
-    return this.scRequest('isStartAllDisabled');
-  }.property('App.router.mainServiceController.isStartStopAllClicked',
-  'App.router.mainServiceController.content.@each.healthStatus'),
-
-  isStopAllDisabled: function() {
-    return this.scRequest('isStopAllDisabled');
-  }.property('App.router.mainServiceController.isStartStopAllClicked',
-  'App.router.mainServiceController.content.@each.healthStatus'),
-
-  gotoAddService: function() {
-    App.router.get('mainServiceController').gotoAddService();
-  },
-
-  startAllService: function(event){
-    App.router.get('mainServiceController').startAllService(event);
-  },
-
-  stopAllService: function(event){
-    App.router.get('mainServiceController').stopAllService(event);
-  },
-
   /**
    * check server version and web client version
    */

+ 1 - 36
ambari-web/app/controllers/main/dashboard.js

@@ -20,40 +20,5 @@ var App = require('app');
 
 App.MainDashboardController = Em.Controller.extend({
   name: 'mainDashboardController',
-  categorySelected: 'widgets',
-
-  scRequest: function(request) {
-    return App.router.get('mainServiceController').get(request);
-  },
-
-  isAllServicesInstalled: function() {
-    return this.scRequest('isAllServicesInstalled');
-  }.property('App.router.mainServiceController.content.content.@each',
-    'App.router.mainServiceController.content.content.length'),
-
-  isStartAllDisabled: function() {
-    return this.scRequest('isStartAllDisabled');
-  }.property('App.router.mainServiceController.isStartStopAllClicked',
-    'App.router.mainServiceController.content.@each.healthStatus'),
-
-  isStopAllDisabled: function() {
-    return this.scRequest('isStopAllDisabled');
-  }.property('App.router.mainServiceController.isStartStopAllClicked',
-    'App.router.mainServiceController.content.@each.healthStatus'),
-
-  gotoAddService: function() {
-    App.router.get('mainServiceController').gotoAddService();
-  },
-
-  startAllService: function(event){
-    App.router.get('mainServiceController').startAllService(event);
-  },
-
-  stopAllService: function(event){
-    App.router.get('mainServiceController').stopAllService(event);
-  },
-
-  restartAllRequired: function(event){
-    App.router.get('mainServiceController').restartAllRequired(event);
-  }
+  categorySelected: 'widgets'
 });

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

@@ -24,36 +24,36 @@
             </a>
             <ul class="pull-left dropdown-menu">
                 {{#isAuthorized "SERVICE.START_STOP"}}
-                    <li {{bindAttr class="controller.isAllServicesInstalled:disabled"}}>
+                    <li {{bindAttr class="view.serviceController.isAllServicesInstalled:disabled"}}>
                         <a href="#"
-                            {{bindAttr class="controller.isAllServicesInstalled:disabled"}}
-                            {{action gotoAddService target="controller"}}>
+                            {{bindAttr class="view.serviceController.isAllServicesInstalled:disabled"}}
+                            {{action gotoAddService target="view.serviceController"}}>
                             <i class="icon-plus icon-white"></i> {{t services.service.add}}</a>
                     </li>
                 {{/isAuthorized}}
                 {{#isAuthorized "SERVICE.ADD_DELETE_SERVICES"}}
                     <li class="divider"></li>
-                    <li {{bindAttr class="controller.isStartAllDisabled:disabled" }}>
+                    <li {{bindAttr class="view.serviceController.isStartAllDisabled:disabled" }}>
                         <a href="#" data-toggle="modal"
-                            {{bindAttr class="controller.isStartAllDisabled:disabled" }}
-                            {{action "startAllService" target="controller"}}>
-                            <i {{bindAttr class=":icon-play controller.isStartAllDisabled:disabled:enabled " }}></i>
+                            {{bindAttr class="view.serviceController.isStartAllDisabled:disabled" }}
+                            {{action "startAllService" target="view.serviceController"}}>
+                            <i {{bindAttr class=":icon-play view.serviceController.isStartAllDisabled:disabled:enabled " }}></i>
                             {{t services.service.startAll}}
                         </a>
                     </li>
-                    <li {{bindAttr class="controller.isStopAllDisabled:disabled" }}>
+                    <li {{bindAttr class="view.serviceController.isStopAllDisabled:disabled" }}>
                         <a href="#" data-toggle="modal"
-                            {{bindAttr class="controller.isStopAllDisabled:disabled" }}
-                            {{action "stopAllService" target="controller"}}>
-                            <i {{bindAttr class=":icon-stop controller.isStopAllDisabled:disabled:enabled" }}></i>
+                            {{bindAttr class="view.serviceController.isStopAllDisabled:disabled" }}
+                            {{action "stopAllService" target="view.serviceController"}}>
+                            <i {{bindAttr class=":icon-stop view.serviceController.isStopAllDisabled:disabled:enabled" }}></i>
                             {{t services.service.stopAll}}
                         </a>
                     </li>
-                    <li {{bindAttr class="controller.isRestartAllRequiredDisabled:disabled" }}>
+                    <li {{bindAttr class="view.serviceController.isRestartAllRequiredDisabled:disabled" }}>
                         <a href="#" data-toggle="modal"
-                            {{bindAttr class="controller.isRestartAllRequiredDisabled:disabled" }}
-                            {{action "restartAllRequired" target="controller"}}>
-                            <i {{bindAttr class=":icon-repeat controller.isRestartAllRequiredDisabled:disabled:enabled" }}></i>
+                            {{bindAttr class="view.serviceController.isRestartAllRequiredDisabled:disabled" }}
+                            {{action "restartAllRequired" target="view.serviceController"}}>
+                            <i {{bindAttr class=":icon-repeat view.serviceController.isRestartAllRequiredDisabled:disabled:enabled" }}></i>
                             {{t services.service.restartAllRequired}}
                         </a>
                     </li>

+ 5 - 1
ambari-web/app/views/main/service/all_services_actions.js

@@ -19,5 +19,9 @@
 var App = require('app');
 
 App.AllServicesActionView = Em.View.extend({
-  templateName: require('templates/main/service/all_services_actions')
+  templateName: require('templates/main/service/all_services_actions'),
+
+  serviceController: function () {
+    return App.get('router.mainServiceController');
+  }.property('App.router.mainServiceController')
 });

+ 0 - 123
ambari-web/test/controllers/main_test.js

@@ -168,129 +168,6 @@ describe('App.MainController', function () {
     });
   });
 
-  describe('#stopAllService', function() {
-    beforeEach(function () {
-      sinon.stub(App.router, 'get').returns({
-        stopAllService: function(func) {
-          if (func) {
-            func();
-          }
-        }
-      });
-    });
-    afterEach(function () {
-      App.router.get.restore();
-    });
-    it ('Should call event', function() {
-      var done = false;
-      var event = function() {
-        done = true;
-      };
-      mainController.stopAllService(event);
-      expect(done).to.be.true;
-    });
-  });
-
-  describe('#startAllService', function() {
-    beforeEach(function () {
-      sinon.stub(App.router, 'get').returns({
-        startAllService: function(func) {
-          if (func) {
-            func();
-          }
-        }
-      });
-    });
-    afterEach(function () {
-      App.router.get.restore();
-    });
-    it ('Should call event', function() {
-      var done = false;
-      var event = function() {
-        done = true;
-      };
-      mainController.startAllService(event);
-      expect(done).to.be.true;
-    });
-  });
-
-  describe('#isStopAllDisabled', function() {
-    beforeEach(function () {
-      sinon.stub(mainController, 'scRequest').returns(true);
-    });
-    afterEach(function () {
-      mainController.scRequest.restore();
-    });
-    it ('Should return true', function() {
-      expect(mainController.get('isStopAllDisabled')).to.be.true;
-    });
-  });
-
-  describe('#gotoAddService', function() {
-    var done = false;
-    beforeEach(function () {
-      sinon.stub(App.router, 'get').returns({
-        gotoAddService: function() {
-          done = true;
-        }
-      });
-    });
-    afterEach(function () {
-      App.router.get.restore();
-    });
-    it ('Should call router', function() {
-      mainController.gotoAddService();
-      expect(done).to.be.true;
-    });
-  });
-
-  describe('#isStartAllDisabled', function() {
-    beforeEach(function () {
-      sinon.stub(mainController, 'scRequest').returns(true);
-    });
-    afterEach(function () {
-      mainController.scRequest.restore();
-    });
-    it ('Should return true', function() {
-      expect(mainController.get('isStartAllDisabled')).to.be.true;
-    });
-  });
-
-  describe('#isAllServicesInstalled', function() {
-    beforeEach(function () {
-      sinon.stub(mainController, 'scRequest').returns(true);
-    });
-    afterEach(function () {
-      mainController.scRequest.restore();
-    });
-    it ('Should return true', function() {
-      expect(mainController.get('isAllServicesInstalled')).to.be.true;
-    });
-  });
-
-  describe('#scRequest', function() {
-    beforeEach(function () {
-      sinon.stub(App.router, 'get').returns({
-        get: function(request) {
-          if (request) {
-            request();
-          }
-        }
-      });
-    });
-    afterEach(function () {
-      App.router.get.restore();
-    });
-    it ('Should return true', function() {
-      var done = false;
-      var event = function() {
-        done = true;
-      };
-      mainController.scRequest(event);
-      expect(done).to.be.true;
-    });
-  });
-
   describe('#updateTitle', function() {
     beforeEach(function () {
       sinon.stub(App.router, 'get', function(message){