mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Transformations: GroupToMatrix add 0 as special value (#97642)
* Add support for 0 empty value * Remove only * Add zero option
This commit is contained in:
parent
e0af98dec8
commit
c901b76a8a
@ -105,11 +105,18 @@ describe('Grouping to Matrix', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('generates Matrix with empty entries', async () => {
|
||||
it.each([
|
||||
[undefined, ''],
|
||||
[SpecialValue.Null, null],
|
||||
[SpecialValue.False, false],
|
||||
[SpecialValue.True, true],
|
||||
[SpecialValue.Empty, ''],
|
||||
[SpecialValue.Zero, 0],
|
||||
])('generates Matrix with empty entries', async (emptyValue, expectedValue) => {
|
||||
const cfg: DataTransformerConfig<GroupingToMatrixTransformerOptions> = {
|
||||
id: DataTransformerID.groupingToMatrix,
|
||||
options: {
|
||||
emptyValue: SpecialValue.Null,
|
||||
emptyValue: emptyValue,
|
||||
},
|
||||
};
|
||||
|
||||
@ -133,13 +140,13 @@ describe('Grouping to Matrix', () => {
|
||||
{
|
||||
name: '1000',
|
||||
type: FieldType.number,
|
||||
values: [1, null],
|
||||
values: [1, expectedValue],
|
||||
config: {},
|
||||
},
|
||||
{
|
||||
name: '1001',
|
||||
type: FieldType.number,
|
||||
values: [null, 2],
|
||||
values: [expectedValue, 2],
|
||||
config: {},
|
||||
},
|
||||
];
|
||||
|
@ -183,6 +183,8 @@ function getSpecialValue(specialValue: SpecialValue) {
|
||||
return true;
|
||||
case SpecialValue.Null:
|
||||
return null;
|
||||
case SpecialValue.Zero:
|
||||
return 0;
|
||||
case SpecialValue.Empty:
|
||||
default:
|
||||
return '';
|
||||
|
@ -115,4 +115,5 @@ export enum SpecialValue {
|
||||
False = 'false',
|
||||
Null = 'null',
|
||||
Empty = 'empty',
|
||||
Zero = 'zero',
|
||||
}
|
||||
|
@ -62,6 +62,7 @@ export const GroupingToMatrixTransformerEditor = ({
|
||||
{ label: 'Null', value: SpecialValue.Null, description: 'Null value' },
|
||||
{ label: 'True', value: SpecialValue.True, description: 'Boolean true value' },
|
||||
{ label: 'False', value: SpecialValue.False, description: 'Boolean false value' },
|
||||
{ label: 'Zero', value: SpecialValue.Zero, description: 'Number 0 value' },
|
||||
{ label: 'Empty', value: SpecialValue.Empty, description: 'Empty string' },
|
||||
];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user