Filter by value: respect field config coming from the datasource (#32428)

* Make sure field config is preserved when filtering values and state of the field recalcualted

* Tests update
This commit is contained in:
Dominik Prokop 2021-03-30 09:30:07 +02:00 committed by GitHub
parent 3fcff2555a
commit 79dafe17a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 18 deletions

View File

@ -56,15 +56,13 @@ describe('FilterByValue transformer', () => {
name: 'time',
type: FieldType.time,
values: new ArrayVector([6000, 7000]),
state: { displayName: 'time' },
config: {},
state: {},
},
{
name: 'numbers',
type: FieldType.number,
values: new ArrayVector([6, 7]),
state: { displayName: 'numbers' },
config: {},
state: {},
},
]);
});
@ -99,15 +97,13 @@ describe('FilterByValue transformer', () => {
name: 'time',
type: FieldType.time,
values: new ArrayVector([1000, 2000, 3000, 4000, 5000]),
state: { displayName: 'time' },
config: {},
state: {},
},
{
name: 'numbers',
type: FieldType.number,
values: new ArrayVector([1, 2, 3, 4, 5]),
state: { displayName: 'numbers' },
config: {},
state: {},
},
]);
});
@ -151,15 +147,13 @@ describe('FilterByValue transformer', () => {
name: 'time',
type: FieldType.time,
values: new ArrayVector([1000, 2000, 3000, 4000, 7000]),
state: { displayName: 'time' },
config: {},
state: {},
},
{
name: 'numbers',
type: FieldType.number,
values: new ArrayVector([1, 2, 3, 4, 7]),
state: { displayName: 'numbers' },
config: {},
state: {},
},
]);
});
@ -203,15 +197,13 @@ describe('FilterByValue transformer', () => {
name: 'time',
type: FieldType.time,
values: new ArrayVector([4000, 5000]),
state: { displayName: 'time' },
config: {},
state: {},
},
{
name: 'numbers',
type: FieldType.number,
values: new ArrayVector([4, 5]),
state: { displayName: 'numbers' },
config: {},
state: {},
},
]);
});

View File

@ -110,11 +110,11 @@ export const filterByValueTransformer: DataTransformerInfo<FilterByValueTransfor
}
}
// TODO: what parts needs to be excluded from field.
// We keep field config, but clean the state as it's being recalculated when the field overrides are applied
fields.push({
...field,
values: new ArrayVector(buffer),
config: {},
state: {},
});
}