Procházet zdrojové kódy

AMBARI-10045. Host detail page: Component action button isn't disabled while it's action list is empty (alexantonenko)

Alex Antonenko před 10 roky
rodič
revize
d786be4ae6

+ 3 - 2
ambari-web/app/views/main/host/details/host_component_view.js

@@ -103,11 +103,12 @@ App.HostComponentView = Em.View.extend({
   /**
   /**
    * CSS-class for disabling drop-down menu with list of host component actions
    * CSS-class for disabling drop-down menu with list of host component actions
    * Disabled if host's <code>healthClass</code> is health-status-DEAD-YELLOW (lost heartbeat)
    * Disabled if host's <code>healthClass</code> is health-status-DEAD-YELLOW (lost heartbeat)
+   * Disabled if component's action list is empty
    * @type {String}
    * @type {String}
    */
    */
   disabled: function () {
   disabled: function () {
-    return (this.get('parentView.content.healthClass') === "health-status-DEAD-YELLOW") ? 'disabled' : '';
-  }.property('parentView.content.healthClass'),
+    return ( (this.get('parentView.content.healthClass') === "health-status-DEAD-YELLOW") || (this.get('noActionAvailable') === 'hidden' && this.get('isRestartComponentDisabled'))) ? 'disabled' : '';
+  }.property('parentView.content.healthClass', 'noActionAvailable', 'isRestartComponentDisabled'),
 
 
   /**
   /**
    * For Upgrade failed state
    * For Upgrade failed state

+ 19 - 1
ambari-web/test/views/main/host/details/host_component_view_test.js

@@ -55,10 +55,26 @@ describe('App.HostComponentView', function() {
     var tests = Em.A([
     var tests = Em.A([
       {
       {
         parentView: {content: {healthClass: 'health-status-DEAD-YELLOW'}},
         parentView: {content: {healthClass: 'health-status-DEAD-YELLOW'}},
+        noActionAvailable: '',
+        isRestartComponentDisabled: true,
         e: 'disabled'
         e: 'disabled'
       },
       },
       {
       {
         parentView: {content: {healthClass: 'another-class'}},
         parentView: {content: {healthClass: 'another-class'}},
+        noActionAvailable: '',
+        isRestartComponentDisabled: true,
+        e: ''
+      },
+      {
+        parentView: {content: {healthClass: 'another-class'}},
+        noActionAvailable: 'hidden',
+        isRestartComponentDisabled: true,
+        e: 'disabled'
+      },
+      {
+        parentView: {content: {healthClass: 'another-class'}},
+        noActionAvailable: 'hidden',
+        isRestartComponentDisabled: false,
         e: ''
         e: ''
       }
       }
     ]);
     ]);
@@ -68,7 +84,9 @@ describe('App.HostComponentView', function() {
         hostComponentView = App.HostComponentView.create({
         hostComponentView = App.HostComponentView.create({
           startBlinking: function(){},
           startBlinking: function(){},
           doBlinking: function(){},
           doBlinking: function(){},
-          parentView: test.parentView
+          parentView: test.parentView,
+          noActionAvailable: test.noActionAvailable,
+          isRestartComponentDisabled: test.isRestartComponentDisabled
         });
         });
         expect(hostComponentView.get('disabled')).to.equal(test.e);
         expect(hostComponentView.get('disabled')).to.equal(test.e);
       });
       });