Kaynağa Gözat

AMBARI-24775 - Configuration warning: insert a space char between label value and unit-name (#2456)

kasakrisz 7 yıl önce
ebeveyn
işleme
78bd9ccd52

+ 5 - 6
ambari-web/app/views/common/configs/widgets/slider_config_widget_view.js

@@ -281,13 +281,13 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
       if (parsed > max) {
         this.set('isMirrorValueValid', false);
         this.get('config').setProperties({
-          warnMessage: Em.I18n.t('config.warnMessage.outOfBoundaries.greater').format(max + this.get('unitLabel')),
+          warnMessage: Em.I18n.t('config.warnMessage.outOfBoundaries.greater').format(this.formatTickLabel(max, ' ')),
           warn: true
         });
       } else if (parsed < min) {
         this.set('isMirrorValueValid', false);
         this.get('config').setProperties({
-          warnMessage: Em.I18n.t('config.warnMessage.outOfBoundaries.less').format(min + this.get('unitLabel')),
+          warnMessage: Em.I18n.t('config.warnMessage.outOfBoundaries.less').format(this.formatTickLabel(min, ' ')),
           warn: true
         });
       } else {
@@ -653,7 +653,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
         var min = this.get('parseFunction')(this.getValueAttributeByGroup('minimum'));
         if (configValue < min) {
           min = this.widgetValueByConfigAttributes(min);
-          this.updateWarningsForCompatibilityWithWidget(Em.I18n.t('config.warnMessage.outOfBoundaries.less').format(min + this.get('unitLabel')));
+          this.updateWarningsForCompatibilityWithWidget(Em.I18n.t('config.warnMessage.outOfBoundaries.less').format(this.formatTickLabel(min, ' ')));
           return false;
         }
       }
@@ -661,7 +661,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
         var max = this.get('parseFunction')(this.getValueAttributeByGroup('maximum'));
         if (configValue > max) {
           max = this.widgetValueByConfigAttributes(max);
-          this.updateWarningsForCompatibilityWithWidget(Em.I18n.t('config.warnMessage.outOfBoundaries.greater').format(max + this.get('unitLabel')));
+          this.updateWarningsForCompatibilityWithWidget(Em.I18n.t('config.warnMessage.outOfBoundaries.greater').format(this.formatTickLabel(max, ' ')));
           return false;
         }
       }
@@ -680,7 +680,6 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
    */
   formatTickLabel: function (tick, separator) {
     var label,
-      separator = separator || '',
       valueLabel = tick,
       units = ['B', 'KB', 'MB', 'GB', 'TB'],
       unitLabel = this.get('unitLabel'),
@@ -693,7 +692,7 @@ App.SliderConfigWidgetView = App.ConfigWidgetView.extend({
       unitLabel = units[unitLabelIndex];
       valueLabel = this._extraRound(tick);
     }
-    label = valueLabel + separator + unitLabel;
+    label = valueLabel + ((separator && unitLabel) ? separator : '') + unitLabel;
     return label;
   }
 

+ 7 - 7
ambari-web/test/views/common/configs/widgets/slider_config_widget_view_test.js

@@ -386,7 +386,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [5, 16, 22, 28, 35, 39, 50],
-          ticksLabels: ['5 ','', '', '28 ', '', '', '50 ']
+          ticksLabels: ['5','', '', '28', '', '', '50']
         }
       },
       {
@@ -403,7 +403,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [1,2],
-          ticksLabels: ['1 ', '2 ']
+          ticksLabels: ['1', '2']
         }
       },
       {
@@ -420,7 +420,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [1,2,3],
-          ticksLabels: ['1 ', '2 ', '3 ']
+          ticksLabels: ['1', '2', '3']
         }
       },
       {
@@ -437,7 +437,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [0,1,2,3],
-          ticksLabels: ['0 ', '1 ', '2 ', '3 ']
+          ticksLabels: ['0', '1', '2', '3']
         }
       },
       {
@@ -454,7 +454,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [1,2,3,4,5],
-          ticksLabels: ['1 ', '', '3 ', '', '5 ']
+          ticksLabels: ['1', '', '3', '', '5']
         }
       },
       {
@@ -471,7 +471,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [0,2,3,5],
-          ticksLabels: ['0 ', '2 ', '3 ', '5 ']
+          ticksLabels: ['0', '2', '3', '5']
         }
       },
       {
@@ -488,7 +488,7 @@ describe('App.SliderConfigWidgetView', function () {
         },
         e: {
           ticks: [0,2,6,12,17,20,23],
-          ticksLabels: ['0 ', '', '', '12 ', '', '', '23 ']
+          ticksLabels: ['0', '', '', '12', '', '', '23']
         }
       },
       {