mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
FieldConfig: Set field config defaults based on config registry (#23376)
* Set field config defaults based on config registry * Rename FIeldPropertyEditorItem to FieldConfigPopertyItem * Remove console.log * Simplify overrides persistence model and add support for nested properties in overrides * Review updates
This commit is contained in:
@@ -3,7 +3,7 @@ import cloneDeep from 'lodash/cloneDeep';
|
||||
import {
|
||||
FieldConfigSource,
|
||||
DataFrame,
|
||||
FieldPropertyEditorItem,
|
||||
FieldConfigPropertyItem,
|
||||
VariableSuggestionsScope,
|
||||
PanelPlugin,
|
||||
SelectableValue,
|
||||
@@ -142,7 +142,7 @@ export const DefaultFieldConfigEditor: React.FC<Props> = ({ data, onChange, conf
|
||||
);
|
||||
|
||||
const renderEditor = useCallback(
|
||||
(item: FieldPropertyEditorItem) => {
|
||||
(item: FieldConfigPropertyItem) => {
|
||||
const defaults = config.defaults;
|
||||
const value = item.isCustom
|
||||
? defaults.custom
|
||||
|
||||
@@ -49,10 +49,9 @@ export const OverrideEditor: React.FC<OverrideEditorProps> = ({ data, override,
|
||||
);
|
||||
|
||||
const onDynamicConfigValueAdd = useCallback(
|
||||
(id: string, custom?: boolean) => {
|
||||
(id: string) => {
|
||||
const propertyConfig: DynamicConfigValue = {
|
||||
id,
|
||||
isCustom: custom,
|
||||
};
|
||||
if (override.properties) {
|
||||
override.properties.push(propertyConfig);
|
||||
@@ -69,7 +68,6 @@ export const OverrideEditor: React.FC<OverrideEditorProps> = ({ data, override,
|
||||
label: item.name,
|
||||
value: item.id,
|
||||
description: item.description,
|
||||
custom: item.isCustom,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -117,7 +115,7 @@ export const OverrideEditor: React.FC<OverrideEditorProps> = ({ data, override,
|
||||
options={configPropertiesOptions}
|
||||
variant={'link'}
|
||||
onChange={o => {
|
||||
onDynamicConfigValueAdd(o.value, o.custom);
|
||||
onDynamicConfigValueAdd(o.value);
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user