mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fix mismatch in field config editor types (#27657)
This commit is contained in:
parent
e32aa99f26
commit
e8a6b9db10
@ -37,7 +37,7 @@ export interface FieldOverrideContext extends StandardEditorContext<any> {
|
||||
}
|
||||
export interface FieldConfigEditorProps<TValue, TSettings>
|
||||
extends Omit<StandardEditorProps<TValue, TSettings>, 'item'> {
|
||||
item: FieldConfigPropertyItem<TValue, TSettings>; // The property info
|
||||
item: FieldConfigPropertyItem<any, TValue, TSettings>; // The property info
|
||||
value: TValue;
|
||||
context: FieldOverrideContext;
|
||||
onChange: (value?: TValue) => void;
|
||||
|
@ -23,7 +23,7 @@ export const ColorValueEditor: React.FC<FieldConfigEditorProps<string, ColorFiel
|
||||
const color = value || (item.defaultValue as string) || theme.colors.panelBg;
|
||||
|
||||
return (
|
||||
<ColorPicker color={color} onChange={onChange} enableNamedColors={!settings.disableNamedColors}>
|
||||
<ColorPicker color={color} onChange={onChange} enableNamedColors={!settings?.disableNamedColors}>
|
||||
{({ ref, showColorPicker, hideColorPicker }) => {
|
||||
return (
|
||||
<div className={styles.spot} onBlur={hideColorPicker}>
|
||||
@ -36,9 +36,9 @@ export const ColorValueEditor: React.FC<FieldConfigEditorProps<string, ColorFiel
|
||||
/>
|
||||
</div>
|
||||
<div className={styles.colorText} onClick={showColorPicker}>
|
||||
{value ?? settings.textWhenUndefined ?? 'Pick Color'}
|
||||
{value ?? settings?.textWhenUndefined ?? 'Pick Color'}
|
||||
</div>
|
||||
{value && settings.allowUndefined && (
|
||||
{value && settings?.allowUndefined && (
|
||||
<Icon className={styles.trashIcon} name="trash-alt" onClick={() => onChange(undefined)} />
|
||||
)}
|
||||
</div>
|
||||
|
@ -24,7 +24,7 @@ export class SelectValueEditor<T> extends React.PureComponent<Props<T>, State<T>
|
||||
const now = this.props.item?.settings;
|
||||
if (old !== now) {
|
||||
this.updateOptions();
|
||||
} else if (now.getOptions) {
|
||||
} else if (now?.getOptions) {
|
||||
const old = oldProps.context?.data;
|
||||
const now = this.props.context?.data;
|
||||
if (old !== now) {
|
||||
@ -53,7 +53,6 @@ export class SelectValueEditor<T> extends React.PureComponent<Props<T>, State<T>
|
||||
const { value, onChange, item } = this.props;
|
||||
|
||||
const { settings } = item;
|
||||
const { allowCustomValue } = settings;
|
||||
let current = options.find(v => v.value === value);
|
||||
if (!current && value) {
|
||||
current = {
|
||||
@ -66,7 +65,7 @@ export class SelectValueEditor<T> extends React.PureComponent<Props<T>, State<T>
|
||||
isLoading={isLoading}
|
||||
value={current}
|
||||
defaultValue={value}
|
||||
allowCustomValue={allowCustomValue}
|
||||
allowCustomValue={settings?.allowCustomValue}
|
||||
onChange={e => onChange(e.value)}
|
||||
options={options}
|
||||
/>
|
||||
|
@ -31,7 +31,7 @@ export const StringValueEditor: React.FC<FieldConfigEditorProps<string, StringFi
|
||||
<Component
|
||||
placeholder={item.settings?.placeholder}
|
||||
defaultValue={value || ''}
|
||||
rows={item.settings?.useTextarea && item.settings.rows}
|
||||
rows={(item.settings?.useTextarea && item.settings.rows) || 5}
|
||||
onBlur={onValueChange}
|
||||
onKeyDown={onValueChange}
|
||||
/>
|
||||
|
Loading…
Reference in New Issue
Block a user