PanelOverrides: Only filter out override properties that do not exist (#87904)

This commit is contained in:
Torkel Ödegaard 2024-05-20 09:48:07 +02:00 committed by GitHub
parent 8e5ce99f72
commit fe991a9a7b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 12 deletions

View File

@ -317,7 +317,7 @@ describe('getPanelOptionsWithDefaults', () => {
`);
});
it('should remove custom overrides that no longer exist', () => {
it('should remove custom override properties that no longer exist', () => {
const result = runScenario({
defaults: {},
overrides: [
@ -342,8 +342,8 @@ describe('getPanelOptionsWithDefaults', () => {
],
});
expect(result.fieldConfig.overrides.length).toBe(1);
expect(result.fieldConfig.overrides[0].properties[0].id).toBe('custom.customProp');
expect(result.fieldConfig.overrides.length).toBe(2);
expect(result.fieldConfig.overrides[0].properties.length).toBe(0);
});
});
});

View File

@ -99,16 +99,14 @@ export function filterFieldConfigOverrides(
overrides: ConfigOverrideRule[],
condition: (value: DynamicConfigValue) => boolean
): ConfigOverrideRule[] {
return overrides
.map((x) => {
const properties = x.properties.filter(condition);
return overrides.map((x) => {
const properties = x.properties.filter(condition);
return {
...x,
properties,
};
})
.filter((x) => x.properties.length > 0);
return {
...x,
properties,
};
});
}
function cleanProperties(obj: object, parentPath: string, fieldConfigRegistry: FieldConfigOptionsRegistry) {