Parcourir la source

AMBARI-15086. SCRIPT alert params should tooltip the description (onechiporenko)

Oleg Nechiporenko il y a 9 ans
Parent
commit
2926a4ecd3

+ 1 - 0
ambari-web/app/controllers/main/alerts/definition_configs_controller.js

@@ -330,6 +330,7 @@ App.MainAlertDefinitionConfigsController = Em.Controller.extend({
       result.push(App.AlertConfigProperties.Parameter.create(mixin, {
         value: isWizard ? '' : parameter.get('value'),
         apiProperty: parameter.get('name'),
+        description: parameter.get('description'),
         label: isWizard ? '' : parameter.get('displayName'),
         threshold: isWizard ? '' : parameter.get('threshold'),
         units: isWizard ? '' : parameter.get('units'),

+ 1 - 1
ambari-web/app/templates/main/alerts/configs/alert_config_parameter.hbs

@@ -24,7 +24,7 @@
         </span>&nbsp;
     </div>
   {{/if}}
-  <div {{bindAttr class="view.bigInput:span12:span3 view.property.units:input-append view.property.thresholdNotExists:stuck-left"}}>
+  <div rel="parameter-tooltip" {{bindAttr data-original-title="view.property.description" class="view.bigInput:span12:span3 view.property.units:input-append view.property.thresholdNotExists:stuck-left"}}>
     {{view Em.TextField valueBinding="view.property.value" disabledBinding="view.property.isDisabled" class ="view.bigInput:span12:span7"}}
     {{#if view.property.units}}
       <span class="add-on">{{view.property.units}}</span>

+ 9 - 1
ambari-web/app/views/main/alerts/definition_configs_view.js

@@ -100,6 +100,14 @@ App.AlertConfigParameterView = Em.View.extend({
 
   bigInput: Em.computed.equal('property.type', 'STRING'),
 
-  classNameBindings: ['property.classNames', 'parentView.basicClass']
+  classNameBindings: ['property.classNames', 'parentView.basicClass'],
+
+  didInsertElement: function () {
+    App.tooltip($("[rel='parameter-tooltip']"));
+  },
+
+  willDestroyElement: function () {
+    $("[rel='parameter-tooltip']").tooltip('destroy');
+  }
 
 });

+ 23 - 13
ambari-web/test/controllers/wizard/step4_test.js

@@ -646,19 +646,29 @@ describe('App.WizardStep4Controller', function () {
     });
 
     cases.forEach(function (item) {
-      it(item.title, function () {
-        controller.set('content', generateSelectedServicesContent(item.services));        
-        controller.serviceDependencyValidation();   
-        expect(controller.get('errorStack').mapProperty('id').contains("serviceCheck_"+item.dependentServices[0])).to.equal(true);        
-        expect(controller.get('errorStack').mapProperty('id').contains("serviceCheck_"+item.dependentServices[1])).to.equal(true);
-        controller.findProperty('serviceName', item.dependentServices[0]).set('isSelected', true);
-        
-        //simulate situation where user clicks cancel on error for first dependent service and then selects it in which case
-        //serviceDependencyValidation() will be called again
-        controller.serviceDependencyValidation();   
-        //error for first dependent service must be removed from errorStack array
-        expect(controller.get('errorStack').mapProperty('id').contains("serviceCheck_"+item.dependentServices[0])).to.equal(false);        
-        expect(controller.get('errorStack').mapProperty('id').contains("serviceCheck_"+item.dependentServices[1])).to.equal(true);
+      describe(item.title, function () {
+
+        beforeEach(function () {
+          controller.set('content', generateSelectedServicesContent(item.services));
+          controller.serviceDependencyValidation();
+        });
+
+        it('check errors in the stack', function () {
+          var ids = controller.get('errorStack').mapProperty('id');
+          expect(ids.contains("serviceCheck_" + item.dependentServices[0])).to.be.true;
+          expect(ids.contains("serviceCheck_" + item.dependentServices[1])).to.be.true;
+        });
+
+        it('simulate situation where user clicks cancel on error for first dependent service and then selects it in which case', function () {
+          controller.findProperty('serviceName', item.dependentServices[0]).set('isSelected', true);
+          //serviceDependencyValidation() will be called again
+          controller.serviceDependencyValidation();
+          //error for first dependent service must be removed from errorStack array
+          var ids = controller.get('errorStack').mapProperty('id');
+          expect(ids.contains("serviceCheck_" + item.dependentServices[0])).to.be.false;
+          expect(ids.contains("serviceCheck_" + item.dependentServices[1])).to.be.true;
+        });
+
       });
     });
   });

+ 0 - 4
ambari-web/test/utils/config_test.js

@@ -23,10 +23,6 @@ require('utils/config');
 require('models/service/hdfs');
 var setups = require('test/init_model_test');
 
-function dummyCopy(val) {
-  return JSON.parse(JSON.stringify(val));
-}
-
 describe('App.config', function () {
 
   describe('#trimProperty',function() {

+ 2 - 2
ambari-web/test/views/main/service/info/summary_test.js

@@ -667,7 +667,7 @@ describe('App.MainServiceInfoSummaryView', function() {
       });
       view.set('controller.widgets', [widget]);
       view.setTimeRange({context: {value: '0'}});
-      expect(widget.get('properties')['time_range']).to.equal('0')
+      expect(widget.get('properties').time_range).to.be.equal('0')
     });
 
     it("range = 1", function() {
@@ -679,7 +679,7 @@ describe('App.MainServiceInfoSummaryView', function() {
       });
       view.set('controller.widgets', [widget]);
       view.setTimeRange({context: {value: '1'}});
-      expect(widget.get('properties')['time_range']).to.equal('1')
+      expect(widget.get('properties').time_range).to.be.equal('1')
     });
   });