[Stack Monitoring] Prefer units if they are defined when rende… (#43709)
* Prefer units if they are defined when rendering cells * Jest snapshot update * Lint recommendations Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
This commit is contained in:
parent
5108eb378d
commit
54d40e3670
|
@ -28,12 +28,12 @@ exports[`Node Listing Metric Cell should format a non-percentage metric 1`] = `
|
|||
<div
|
||||
class="euiText euiText--extraSmall"
|
||||
>
|
||||
206.5 GB max
|
||||
206.5 GB max
|
||||
</div>
|
||||
<div
|
||||
class="euiText euiText--extraSmall"
|
||||
>
|
||||
206.3 GB min
|
||||
206.3 GB min
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
|
@ -21,11 +21,11 @@ const getSlopeArrow = slope => {
|
|||
return null;
|
||||
};
|
||||
|
||||
const metricVal = (metric, format, isPercent) => {
|
||||
const metricVal = (metric, format, isPercent, units) => {
|
||||
if (isPercent) {
|
||||
return formatMetric(metric, format, '%', { prependSpace: false });
|
||||
}
|
||||
return formatMetric(metric, format);
|
||||
return formatMetric(metric, format, units);
|
||||
};
|
||||
|
||||
const noWrapStyle = { overflowX: 'hidden', whiteSpace: 'nowrap' };
|
||||
|
@ -34,6 +34,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) {
|
|||
if (isOnline) {
|
||||
const { lastVal, maxVal, minVal, slope } = get(metric, 'summary', {});
|
||||
const format = get(metric, 'metric.format');
|
||||
const units = get(metric, 'metric.units');
|
||||
|
||||
return (
|
||||
<EuiFlexGroup gutterSize="m" alignItems="center" wrap {...props}>
|
||||
|
@ -49,7 +50,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) {
|
|||
{i18n.translate('xpack.monitoring.elasticsearch.nodes.cells.maxText', {
|
||||
defaultMessage: '{metric} max',
|
||||
values: {
|
||||
metric: metricVal(maxVal, format, isPercent),
|
||||
metric: metricVal(maxVal, format, isPercent, units),
|
||||
},
|
||||
})}
|
||||
</EuiText>
|
||||
|
@ -57,7 +58,7 @@ function MetricCell({ isOnline, metric = {}, isPercent, ...props }) {
|
|||
{i18n.translate('xpack.monitoring.elasticsearch.nodes.cells.minText', {
|
||||
defaultMessage: '{metric} min',
|
||||
values: {
|
||||
metric: metricVal(minVal, format, isPercent),
|
||||
metric: metricVal(minVal, format, isPercent, units),
|
||||
},
|
||||
})}
|
||||
</EuiText>
|
||||
|
|
Loading…
Reference in a new issue