Commit f33521f0 authored by Jose Vargas's avatar Jose Vargas

Rename max_value to maxValue

parent 685228d5
......@@ -27,22 +27,19 @@ export default {
/**
* This method formats the query result from a promQL expression
* allowing a user to format the data in percentile values
* by using the `max_value` inner property from the graphData prop
* by using the `maxValue` inner property from the graphData prop
* @returns {(String)}
*/
statValue() {
let formatter;
let value;
if (this.graphData?.max_value) {
if (this.graphData?.maxValue) {
formatter = getFormatter(SUPPORTED_FORMATS.percent);
value = formatter(this.queryResult / Number(this.graphData.max_value), defaultPrecision);
} else {
formatter = getFormatter(SUPPORTED_FORMATS.number);
value = `${formatter(this.queryResult, defaultPrecision)}${this.queryInfo.unit}`;
return formatter(this.queryResult / Number(this.graphData.maxValue), defaultPrecision);
}
return value;
formatter = getFormatter(SUPPORTED_FORMATS.number);
return `${formatter(this.queryResult, defaultPrecision)}${this.queryInfo.unit}`;
},
graphTitle() {
return this.queryInfo.label;
......
......@@ -126,7 +126,7 @@ const mapPanelToViewModel = ({
y_label: yAxis.name, // Changing y_label to yLabel is pending https://gitlab.com/gitlab-org/gitlab/issues/207198
yAxis,
xAxis,
max_value,
maxValue: max_value,
metrics: mapToMetricsViewModel(metrics, yAxis.name),
};
};
......
......@@ -27,18 +27,18 @@ describe('Single Stat Chart component', () => {
singleStatChart.setProps({
graphData: {
...graphDataPrometheusQuery,
max_value: 120,
maxValue: 120,
},
});
expect(singleStatChart.vm.statValue).toContain('75.83%');
});
it('should display NaN for non numeric max_value values', () => {
it('should display NaN for non numeric maxValue values', () => {
singleStatChart.setProps({
graphData: {
...graphDataPrometheusQuery,
max_value: 'not a number',
maxValue: 'not a number',
},
});
......@@ -60,7 +60,7 @@ describe('Single Stat Chart component', () => {
],
},
],
max_value: 120,
maxValue: 120,
},
});
......
......@@ -222,12 +222,12 @@ describe('mapToDashboardViewModel', () => {
});
// This property allows single_stat panels to render percentile values
it('group max_value', () => {
it('group maxValue', () => {
setupWithPanel({
max_value: 100,
});
expect(getMappedPanel().max_value).toBe(100);
expect(getMappedPanel().maxValue).toBe(100);
});
});
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment