Fix static value converter (#144034)

This commit is contained in:
Uladzislau Lasitsa 2022-10-27 10:28:13 +03:00 committed by GitHub
parent 7839589d46
commit 8eeb9e2fa2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View file

@ -47,6 +47,11 @@ describe('convertToStaticValueColumn', () => {
[{ series, metrics: [metric], dataView }, { visibleSeriesCount: 1 }],
null,
],
[
'null if value is not specified',
[{ series, metrics: [metric], dataView }, { visibleSeriesCount: 2 }],
null,
],
[
'static value column',
[{ series, metrics: [{ ...metric, value: 'some value' }], dataView }],

View file

@ -32,6 +32,9 @@ export const convertToStaticValueColumn = (
return null;
}
const currentMetric = metrics[metrics.length - 1];
if (!currentMetric.value) {
return null;
}
return {
operationType: 'static_value',
references: [],
@ -68,7 +71,10 @@ export const convertStaticValueToFormulaColumn = (
return null;
}
const currentMetric = metrics[metrics.length - 1];
return createFormulaColumn(currentMetric.value ?? '', {
if (!currentMetric.value) {
return null;
}
return createFormulaColumn(currentMetric.value, {
series,
metric: currentMetric,
dataView,