mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
PanelOverrides: Only filter out override properties that do not exist (#87904)
This commit is contained in:
parent
8e5ce99f72
commit
fe991a9a7b
@ -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({
|
const result = runScenario({
|
||||||
defaults: {},
|
defaults: {},
|
||||||
overrides: [
|
overrides: [
|
||||||
@ -342,8 +342,8 @@ describe('getPanelOptionsWithDefaults', () => {
|
|||||||
],
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
expect(result.fieldConfig.overrides.length).toBe(1);
|
expect(result.fieldConfig.overrides.length).toBe(2);
|
||||||
expect(result.fieldConfig.overrides[0].properties[0].id).toBe('custom.customProp');
|
expect(result.fieldConfig.overrides[0].properties.length).toBe(0);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -99,16 +99,14 @@ export function filterFieldConfigOverrides(
|
|||||||
overrides: ConfigOverrideRule[],
|
overrides: ConfigOverrideRule[],
|
||||||
condition: (value: DynamicConfigValue) => boolean
|
condition: (value: DynamicConfigValue) => boolean
|
||||||
): ConfigOverrideRule[] {
|
): ConfigOverrideRule[] {
|
||||||
return overrides
|
return overrides.map((x) => {
|
||||||
.map((x) => {
|
const properties = x.properties.filter(condition);
|
||||||
const properties = x.properties.filter(condition);
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...x,
|
...x,
|
||||||
properties,
|
properties,
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
.filter((x) => x.properties.length > 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function cleanProperties(obj: object, parentPath: string, fieldConfigRegistry: FieldConfigOptionsRegistry) {
|
function cleanProperties(obj: object, parentPath: string, fieldConfigRegistry: FieldConfigOptionsRegistry) {
|
||||||
|
Loading…
Reference in New Issue
Block a user