Prometheus: Fixes issue where legend name was replaced with name Value in stat & gauge panels (#35863)

This commit is contained in:
Torkel Ödegaard 2021-06-17 20:59:28 +02:00 committed by GitHub
parent e1e2bd545a
commit 22203fd4df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 31 additions and 1 deletions

View File

@ -411,6 +411,36 @@ describe('FieldDisplay', () => {
expect(result[1].display.title).toEqual('Norway Oslo');
expect(result[1].display.text).toEqual('20');
});
it('When showing all values for field with displayNameFromDS', () => {
const options = createDisplayOptions({
reduceOptions: {
values: true,
calcs: [],
},
fieldConfig: { overrides: [], defaults: {} },
data: [
toDataFrame({
fields: [
{
name: 'Time',
values: [1],
},
{
name: 'Value',
values: [10],
config: {
displayNameFromDS: 'NewName',
},
},
],
}),
],
});
const result = getFieldDisplayValues(options);
expect(result[0].display.title).toEqual('NewName');
});
});
});

View File

@ -274,7 +274,7 @@ function getSmartDisplayNameForRow(
}
if (otherNumericFields || parts.length === 0) {
parts.push(getFieldDisplayName(field));
parts.push(getFieldDisplayName(field, frame));
}
return parts.join(' ');