Chore: Deprecate FieldConfigEditorProps in favor of StandardEditorProps (#78319)

* Deprecate FieldConfigEditorProps in favor of StandardEditorProps

* update editors to no longer use FieldOverrideEditorProps
This commit is contained in:
Josh Hunt 2023-12-07 11:03:18 +00:00 committed by GitHub
parent 4a0c89a8fd
commit 8ce4faf5ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
23 changed files with 151 additions and 294 deletions

View File

@ -303,8 +303,7 @@ exports[`better eslint`] = {
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
[0, 0, 0, "Unexpected any. Specify a different type.", "11"]
],
"packages/grafana-data/src/types/flot.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -385,97 +384,31 @@ exports[`better eslint`] = {
"packages/grafana-data/src/utils/OptionsUIBuilders.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Do not use any type assertions.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"],
[0, 0, 0, "Do not use any type assertions.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Do not use any type assertions.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"],
[0, 0, 0, "Do not use any type assertions.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Do not use any type assertions.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Unexpected any. Specify a different type.", "28"],
[0, 0, 0, "Do not use any type assertions.", "29"],
[0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Do not use any type assertions.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Unexpected any. Specify a different type.", "33"],
[0, 0, 0, "Do not use any type assertions.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Do not use any type assertions.", "36"],
[0, 0, 0, "Unexpected any. Specify a different type.", "37"],
[0, 0, 0, "Unexpected any. Specify a different type.", "38"],
[0, 0, 0, "Do not use any type assertions.", "39"],
[0, 0, 0, "Unexpected any. Specify a different type.", "40"],
[0, 0, 0, "Do not use any type assertions.", "41"],
[0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Unexpected any. Specify a different type.", "43"],
[0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Do not use any type assertions.", "45"],
[0, 0, 0, "Unexpected any. Specify a different type.", "46"],
[0, 0, 0, "Do not use any type assertions.", "47"],
[0, 0, 0, "Unexpected any. Specify a different type.", "48"],
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
[0, 0, 0, "Unexpected any. Specify a different type.", "51"],
[0, 0, 0, "Unexpected any. Specify a different type.", "52"],
[0, 0, 0, "Unexpected any. Specify a different type.", "53"],
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Unexpected any. Specify a different type.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Unexpected any. Specify a different type.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Do not use any type assertions.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"],
[0, 0, 0, "Do not use any type assertions.", "63"],
[0, 0, 0, "Unexpected any. Specify a different type.", "64"],
[0, 0, 0, "Do not use any type assertions.", "65"],
[0, 0, 0, "Unexpected any. Specify a different type.", "66"],
[0, 0, 0, "Do not use any type assertions.", "67"],
[0, 0, 0, "Unexpected any. Specify a different type.", "68"],
[0, 0, 0, "Do not use any type assertions.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Unexpected any. Specify a different type.", "75"],
[0, 0, 0, "Do not use any type assertions.", "76"],
[0, 0, 0, "Unexpected any. Specify a different type.", "77"],
[0, 0, 0, "Unexpected any. Specify a different type.", "78"],
[0, 0, 0, "Do not use any type assertions.", "79"],
[0, 0, 0, "Unexpected any. Specify a different type.", "80"],
[0, 0, 0, "Unexpected any. Specify a different type.", "81"],
[0, 0, 0, "Do not use any type assertions.", "82"],
[0, 0, 0, "Unexpected any. Specify a different type.", "83"],
[0, 0, 0, "Unexpected any. Specify a different type.", "84"],
[0, 0, 0, "Do not use any type assertions.", "85"],
[0, 0, 0, "Unexpected any. Specify a different type.", "86"],
[0, 0, 0, "Unexpected any. Specify a different type.", "87"],
[0, 0, 0, "Do not use any type assertions.", "88"],
[0, 0, 0, "Unexpected any. Specify a different type.", "89"],
[0, 0, 0, "Unexpected any. Specify a different type.", "90"],
[0, 0, 0, "Do not use any type assertions.", "91"],
[0, 0, 0, "Unexpected any. Specify a different type.", "92"]
[0, 0, 0, "Unexpected any. Specify a different type.", "26"]
],
"packages/grafana-data/src/utils/Registry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
@ -954,9 +887,6 @@ exports[`better eslint`] = {
"packages/grafana-ui/src/options/builder/hideSeries.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
"packages/grafana-ui/src/options/builder/stacking.tsx:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"packages/grafana-ui/src/slate-plugins/braces.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"]
],
@ -1071,85 +1001,17 @@ exports[`better eslint`] = {
[0, 0, 0, "Styles should be written using objects.", "0"]
],
"public/app/core/components/OptionsUI/registry.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
[0, 0, 0, "Do not use any type assertions.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "4"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Do not use any type assertions.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Do not use any type assertions.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
[0, 0, 0, "Do not use any type assertions.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
[0, 0, 0, "Do not use any type assertions.", "12"],
[0, 0, 0, "Unexpected any. Specify a different type.", "13"],
[0, 0, 0, "Do not use any type assertions.", "14"],
[0, 0, 0, "Unexpected any. Specify a different type.", "15"],
[0, 0, 0, "Do not use any type assertions.", "16"],
[0, 0, 0, "Unexpected any. Specify a different type.", "17"],
[0, 0, 0, "Do not use any type assertions.", "18"],
[0, 0, 0, "Unexpected any. Specify a different type.", "19"],
[0, 0, 0, "Unexpected any. Specify a different type.", "20"],
[0, 0, 0, "Do not use any type assertions.", "21"],
[0, 0, 0, "Unexpected any. Specify a different type.", "22"],
[0, 0, 0, "Do not use any type assertions.", "23"],
[0, 0, 0, "Unexpected any. Specify a different type.", "24"],
[0, 0, 0, "Unexpected any. Specify a different type.", "25"],
[0, 0, 0, "Do not use any type assertions.", "26"],
[0, 0, 0, "Unexpected any. Specify a different type.", "27"],
[0, 0, 0, "Do not use any type assertions.", "28"],
[0, 0, 0, "Unexpected any. Specify a different type.", "29"],
[0, 0, 0, "Unexpected any. Specify a different type.", "30"],
[0, 0, 0, "Do not use any type assertions.", "31"],
[0, 0, 0, "Unexpected any. Specify a different type.", "32"],
[0, 0, 0, "Do not use any type assertions.", "33"],
[0, 0, 0, "Unexpected any. Specify a different type.", "34"],
[0, 0, 0, "Unexpected any. Specify a different type.", "35"],
[0, 0, 0, "Do not use any type assertions.", "36"],
[0, 0, 0, "Unexpected any. Specify a different type.", "37"],
[0, 0, 0, "Do not use any type assertions.", "38"],
[0, 0, 0, "Unexpected any. Specify a different type.", "39"],
[0, 0, 0, "Unexpected any. Specify a different type.", "40"],
[0, 0, 0, "Do not use any type assertions.", "41"],
[0, 0, 0, "Unexpected any. Specify a different type.", "42"],
[0, 0, 0, "Do not use any type assertions.", "43"],
[0, 0, 0, "Unexpected any. Specify a different type.", "44"],
[0, 0, 0, "Unexpected any. Specify a different type.", "45"],
[0, 0, 0, "Do not use any type assertions.", "46"],
[0, 0, 0, "Unexpected any. Specify a different type.", "47"],
[0, 0, 0, "Do not use any type assertions.", "48"],
[0, 0, 0, "Unexpected any. Specify a different type.", "49"],
[0, 0, 0, "Unexpected any. Specify a different type.", "50"],
[0, 0, 0, "Do not use any type assertions.", "51"],
[0, 0, 0, "Unexpected any. Specify a different type.", "52"],
[0, 0, 0, "Do not use any type assertions.", "53"],
[0, 0, 0, "Unexpected any. Specify a different type.", "54"],
[0, 0, 0, "Unexpected any. Specify a different type.", "55"],
[0, 0, 0, "Do not use any type assertions.", "56"],
[0, 0, 0, "Unexpected any. Specify a different type.", "57"],
[0, 0, 0, "Do not use any type assertions.", "58"],
[0, 0, 0, "Unexpected any. Specify a different type.", "59"],
[0, 0, 0, "Unexpected any. Specify a different type.", "60"],
[0, 0, 0, "Do not use any type assertions.", "61"],
[0, 0, 0, "Unexpected any. Specify a different type.", "62"],
[0, 0, 0, "Do not use any type assertions.", "63"],
[0, 0, 0, "Unexpected any. Specify a different type.", "64"],
[0, 0, 0, "Unexpected any. Specify a different type.", "65"],
[0, 0, 0, "Do not use any type assertions.", "66"],
[0, 0, 0, "Unexpected any. Specify a different type.", "67"],
[0, 0, 0, "Do not use any type assertions.", "68"],
[0, 0, 0, "Unexpected any. Specify a different type.", "69"],
[0, 0, 0, "Unexpected any. Specify a different type.", "70"],
[0, 0, 0, "Do not use any type assertions.", "71"],
[0, 0, 0, "Unexpected any. Specify a different type.", "72"],
[0, 0, 0, "Do not use any type assertions.", "73"],
[0, 0, 0, "Unexpected any. Specify a different type.", "74"],
[0, 0, 0, "Do not use any type assertions.", "75"],
[0, 0, 0, "Unexpected any. Specify a different type.", "76"],
[0, 0, 0, "Do not use any type assertions.", "77"],
[0, 0, 0, "Unexpected any. Specify a different type.", "78"]
[0, 0, 0, "Unexpected any. Specify a different type.", "10"]
],
"public/app/core/components/PageHeader/PageHeader.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"],
@ -6446,12 +6308,6 @@ exports[`better eslint`] = {
"public/app/plugins/panel/heatmap/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/plugins/panel/heatmap/module.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
[0, 0, 0, "Do not use any type assertions.", "2"],
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
],
"public/app/plugins/panel/heatmap/palettes.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"]

View File

@ -19,10 +19,14 @@ export interface StandardEditorContext<TOptions, TState = any> {
export interface StandardEditorProps<TValue = any, TSettings = any, TOptions = any, TState = any> {
value: TValue;
onChange: (value?: TValue) => void;
item: StandardEditorsRegistryItem<TValue, TSettings>;
context: StandardEditorContext<TOptions, TState>;
id?: string;
item: RegistryItem & {
settings?: TSettings;
};
}
export interface StandardEditorsRegistryItem<TValue = any, TSettings = any> extends RegistryItem {
editor: ComponentType<StandardEditorProps<TValue, TSettings>>;
settings?: TSettings;

View File

@ -73,18 +73,12 @@ export interface FieldOverrideContext extends StandardEditorContext<any, any> {
field?: Field;
dataFrameIndex?: number; // The index for the selected field frame
}
export interface FieldConfigEditorProps<TValue, TSettings extends {}>
extends Omit<StandardEditorProps<TValue, TSettings>, 'item'> {
item: FieldConfigPropertyItem<any, TValue, TSettings>; // The property info
value: TValue;
context: FieldOverrideContext;
onChange: (value?: TValue) => void;
}
export interface FieldOverrideEditorProps<TValue, TSettings> extends Omit<StandardEditorProps<TValue>, 'item'> {
item: FieldConfigPropertyItem<TValue, TSettings>;
context: FieldOverrideContext;
}
/** @deprecated Use StandardEditorProps instead */
export type FieldConfigEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;
/** @deprecated Use StandardEditorProps instead */
export type FieldOverrideEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;
export interface FieldConfigEditorConfig<TOptions, TSettings = any, TValue = any>
extends OptionEditorConfig<TOptions, TSettings, TValue> {
@ -102,9 +96,9 @@ export interface FieldConfigEditorConfig<TOptions, TSettings = any, TValue = any
}
export interface FieldConfigPropertyItem<TOptions = any, TValue = any, TSettings extends {} = any>
extends OptionsEditorItem<TOptions, TSettings, FieldConfigEditorProps<TValue, TSettings>, TValue> {
extends OptionsEditorItem<TOptions, TSettings, StandardEditorProps<TValue, TSettings>, TValue> {
// An editor that can be filled in with context info (template variables etc)
override: ComponentType<FieldOverrideEditorProps<TValue, TSettings>>;
override: ComponentType<StandardEditorProps<TValue, TSettings>>;
/** true for plugin field config properties */
isCustom?: boolean;

View File

@ -18,7 +18,7 @@ import {
import { PanelOptionsSupplier } from '../panel/PanelPlugin';
import { isObject } from '../types';
import { OptionsEditorItem, OptionsUIRegistryBuilder } from '../types/OptionsUIRegistryBuilder';
import { FieldConfigEditorProps, FieldConfigPropertyItem, FieldConfigEditorConfig } from '../types/fieldOverrides';
import { FieldConfigPropertyItem, FieldConfigEditorConfig } from '../types/fieldOverrides';
import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel';
/**
@ -26,15 +26,15 @@ import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel
*/
export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder<
TOptions,
FieldConfigEditorProps<any, any>,
StandardEditorProps<any, any>,
FieldConfigPropertyItem<TOptions>
> {
addNumberInput<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings & NumberFieldConfigSettings, number>) {
return this.addCustomEditor({
...config,
id: config.path,
override: standardEditorsRegistry.get('number').editor as any,
editor: standardEditorsRegistry.get('number').editor as any,
override: standardEditorsRegistry.get('number').editor,
editor: standardEditorsRegistry.get('number').editor,
process: numberOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {},
@ -45,8 +45,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
override: standardEditorsRegistry.get('slider').editor as any,
editor: standardEditorsRegistry.get('slider').editor as any,
override: standardEditorsRegistry.get('slider').editor,
editor: standardEditorsRegistry.get('slider').editor,
process: numberOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {},
@ -57,8 +57,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
override: standardEditorsRegistry.get('text').editor as any,
editor: standardEditorsRegistry.get('text').editor as any,
override: standardEditorsRegistry.get('text').editor,
editor: standardEditorsRegistry.get('text').editor,
process: stringOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {},
@ -71,8 +71,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
override: standardEditorsRegistry.get('select').editor as any,
editor: standardEditorsRegistry.get('select').editor as any,
override: standardEditorsRegistry.get('select').editor,
editor: standardEditorsRegistry.get('select').editor,
process: selectOverrideProcessor,
// ???
shouldApply: config.shouldApply ? config.shouldApply : () => true,
@ -84,8 +84,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
override: standardEditorsRegistry.get('radio').editor as any,
editor: standardEditorsRegistry.get('radio').editor as any,
override: standardEditorsRegistry.get('radio').editor,
editor: standardEditorsRegistry.get('radio').editor,
process: selectOverrideProcessor,
// ???
shouldApply: config.shouldApply ? config.shouldApply : () => true,
@ -97,8 +97,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('boolean').editor as any,
override: standardEditorsRegistry.get('boolean').editor as any,
editor: standardEditorsRegistry.get('boolean').editor,
override: standardEditorsRegistry.get('boolean').editor,
process: booleanOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
@ -109,8 +109,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('color').editor as any,
override: standardEditorsRegistry.get('color').editor as any,
editor: standardEditorsRegistry.get('color').editor,
override: standardEditorsRegistry.get('color').editor,
process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
@ -123,8 +123,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('unit').editor as any,
override: standardEditorsRegistry.get('unit').editor as any,
editor: standardEditorsRegistry.get('unit').editor,
override: standardEditorsRegistry.get('unit').editor,
process: unitOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
@ -137,8 +137,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('field-name').editor as any,
override: standardEditorsRegistry.get('field-name').editor as any,
editor: standardEditorsRegistry.get('field-name').editor,
override: standardEditorsRegistry.get('field-name').editor,
process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
@ -152,8 +152,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({
...config,
id: config.path,
editor: editor as any,
override: editor as any,
editor: editor,
override: editor,
process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {},
@ -226,7 +226,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('number').editor as any,
editor: standardEditorsRegistry.get('number').editor,
});
}
@ -234,7 +234,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('slider').editor as any,
editor: standardEditorsRegistry.get('slider').editor,
});
}
@ -242,7 +242,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('text').editor as any,
editor: standardEditorsRegistry.get('text').editor,
});
}
@ -252,7 +252,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('strings').editor as any,
editor: standardEditorsRegistry.get('strings').editor,
});
}
@ -262,7 +262,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('select').editor as any,
editor: standardEditorsRegistry.get('select').editor,
});
}
@ -272,7 +272,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('multi-select').editor as any,
editor: standardEditorsRegistry.get('multi-select').editor,
});
}
@ -282,7 +282,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('radio').editor as any,
editor: standardEditorsRegistry.get('radio').editor,
});
}
@ -290,7 +290,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('boolean').editor as any,
editor: standardEditorsRegistry.get('boolean').editor,
});
}
@ -298,7 +298,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('color').editor as any,
editor: standardEditorsRegistry.get('color').editor,
settings: config.settings || {},
});
}
@ -307,7 +307,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('timezone').editor as any,
editor: standardEditorsRegistry.get('timezone').editor,
settings: config.settings || {},
});
}
@ -318,7 +318,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('unit').editor as any,
editor: standardEditorsRegistry.get('unit').editor,
});
}
@ -328,7 +328,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('field-name').editor as any,
editor: standardEditorsRegistry.get('field-name').editor,
});
}
@ -338,7 +338,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({
...config,
id: config.path,
editor: standardEditorsRegistry.get('dashboard-uid').editor as any, // added at runtime
editor: standardEditorsRegistry.get('dashboard-uid').editor, // added at runtime
});
}
}

View File

@ -1,13 +1,13 @@
import { startCase } from 'lodash';
import React, { useCallback } from 'react';
import { FieldConfigEditorBuilder, FieldConfigEditorProps } from '@grafana/data';
import { FieldConfigEditorBuilder, StandardEditorProps } from '@grafana/data';
import { HideableFieldConfig, HideSeriesConfig } from '@grafana/schema';
import { FilterPill } from '../../components/FilterPill/FilterPill';
import { HorizontalGroup } from '../../components/Layout/Layout';
const SeriesConfigEditor = ({ value, onChange }: FieldConfigEditorProps<HideSeriesConfig, {}>) => {
const SeriesConfigEditor = ({ value, onChange }: StandardEditorProps<HideSeriesConfig, {}>) => {
const onChangeToggle = useCallback(
(prop: keyof HideSeriesConfig) => {
onChange({ ...value, [prop]: !value[prop] });

View File

@ -2,9 +2,10 @@ import React from 'react';
import {
FieldConfigEditorBuilder,
FieldOverrideEditorProps,
StandardEditorProps,
FieldType,
identityOverrideProcessor,
SelectableValue,
} from '@grafana/data';
import { GraphFieldConfig, StackingConfig, StackingMode } from '@grafana/schema';
@ -14,12 +15,17 @@ import { Input } from '../../components/Input/Input';
import { HorizontalGroup } from '../../components/Layout/Layout';
import { graphFieldOptions } from '../../components/uPlot/config';
export const StackingEditor = ({ value, context, onChange, item }: FieldOverrideEditorProps<StackingConfig, any>) => {
export const StackingEditor = ({
value,
context,
onChange,
item,
}: StandardEditorProps<StackingConfig, { options: Array<SelectableValue<StackingMode>> }>) => {
return (
<HorizontalGroup>
<RadioButtonGroup
value={value?.mode || StackingMode.None}
options={item.settings.options}
options={item.settings?.options ?? []}
onChange={(v) => {
onChange({
...value,

View File

@ -2,7 +2,7 @@ import { css } from '@emotion/css';
import React, { CSSProperties, FC } from 'react';
import {
FieldConfigEditorProps,
StandardEditorProps,
FieldColorModeId,
SelectableValue,
FieldColor,
@ -17,7 +17,7 @@ import { useStyles2, useTheme2, Field, RadioButtonGroup, Select } from '@grafana
import { ColorValueEditor } from './color';
type Props = FieldConfigEditorProps<FieldColor | undefined, FieldColorConfigSettings>;
type Props = StandardEditorProps<FieldColor | undefined, FieldColorConfigSettings>;
export const FieldColorEditor = ({ value, onChange, item, id }: Props) => {
const theme = useTheme2();

View File

@ -1,14 +1,9 @@
import React from 'react';
import {
DataLink,
DataLinksFieldConfigSettings,
FieldConfigEditorProps,
VariableSuggestionsScope,
} from '@grafana/data';
import { DataLink, DataLinksFieldConfigSettings, StandardEditorProps, VariableSuggestionsScope } from '@grafana/data';
import { DataLinksInlineEditor } from '@grafana/ui';
type Props = FieldConfigEditorProps<DataLink[], DataLinksFieldConfigSettings>;
type Props = StandardEditorProps<DataLink[], DataLinksFieldConfigSettings>;
export const DataLinksValueEditor = ({ value, onChange, context }: Props) => {
return (

View File

@ -1,6 +1,6 @@
import React from 'react';
import { FieldConfigEditorProps, SelectFieldConfigSettings, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectFieldConfigSettings, SelectableValue } from '@grafana/data';
import { MultiSelect } from '@grafana/ui';
interface State<T> {
@ -8,7 +8,7 @@ interface State<T> {
options: Array<SelectableValue<T>>;
}
type Props<T> = FieldConfigEditorProps<T[], SelectFieldConfigSettings<T>>;
type Props<T> = StandardEditorProps<T[], SelectFieldConfigSettings<T>>;
/**
* MultiSelect for options UI

View File

@ -1,10 +1,10 @@
import React, { useCallback } from 'react';
import { FieldConfigEditorProps, NumberFieldConfigSettings } from '@grafana/data';
import { StandardEditorProps, NumberFieldConfigSettings } from '@grafana/data';
import { NumberInput } from './NumberInput';
type Props = FieldConfigEditorProps<number, NumberFieldConfigSettings>;
type Props = StandardEditorProps<number, NumberFieldConfigSettings>;
export const NumberValueEditor = ({ value, onChange, item }: Props) => {
const { settings } = item;

View File

@ -55,14 +55,14 @@ export const getAllOptionEditors = () => {
id: 'number',
name: 'Number',
description: 'Allows numeric values input',
editor: NumberValueEditor as any,
editor: NumberValueEditor,
};
const slider: StandardEditorsRegistryItem<number> = {
id: 'slider',
name: 'Slider',
description: 'Allows numeric values input',
editor: SliderValueEditor as any,
editor: SliderValueEditor,
};
const text: StandardEditorsRegistryItem<string> = {
@ -76,7 +76,7 @@ export const getAllOptionEditors = () => {
id: 'strings',
name: 'String array',
description: 'An array of strings',
editor: StringArrayEditor as any,
editor: StringArrayEditor,
};
const boolean: StandardEditorsRegistryItem<boolean> = {
@ -93,14 +93,14 @@ export const getAllOptionEditors = () => {
id: 'select',
name: 'Select',
description: 'Allows option selection',
editor: SelectValueEditor as any,
editor: SelectValueEditor,
};
const multiSelect: StandardEditorsRegistryItem = {
id: 'multi-select',
name: 'Multi select',
description: 'Allows for multiple option selection',
editor: MultiSelectValueEditor as any,
editor: MultiSelectValueEditor,
};
const radio: StandardEditorsRegistryItem = {
@ -116,7 +116,7 @@ export const getAllOptionEditors = () => {
id: 'unit',
name: 'Unit',
description: 'Allows unit input',
editor: UnitValueEditor as any,
editor: UnitValueEditor,
};
const color: StandardEditorsRegistryItem<string, ColorValueEditorSettings> = {
@ -130,24 +130,24 @@ export const getAllOptionEditors = () => {
},
};
const fieldColor: StandardEditorsRegistryItem<FieldColor> = {
const fieldColor: StandardEditorsRegistryItem<FieldColor | undefined> = {
id: 'fieldColor',
name: 'Field Color',
description: 'Field color selection',
editor: FieldColorEditor as any,
editor: FieldColorEditor,
};
const links: StandardEditorsRegistryItem<DataLink[]> = {
id: 'links',
name: 'Links',
description: 'Allows defining data links',
editor: DataLinksValueEditor as any,
editor: DataLinksValueEditor,
};
const statsPicker: StandardEditorsRegistryItem<string[], StatsPickerConfigSettings> = {
id: 'stats-picker',
name: 'Stats Picker',
editor: StatsPickerEditor as any,
editor: StatsPickerEditor,
description: '',
};
@ -183,7 +183,7 @@ export const getAllOptionEditors = () => {
id: 'thresholds',
name: 'Thresholds',
description: 'Allows defining thresholds',
editor: ThresholdsValueEditor as any,
editor: ThresholdsValueEditor,
};
return [
@ -218,8 +218,8 @@ export const getAllStandardFieldConfigs = () => {
path: 'displayName',
name: 'Display name',
description: 'Change the field or series name',
editor: standardEditorsRegistry.get('text').editor as any,
override: standardEditorsRegistry.get('text').editor as any,
editor: standardEditorsRegistry.get('text').editor,
override: standardEditorsRegistry.get('text').editor,
process: displayNameOverrideProcessor,
settings: {
placeholder: 'none',
@ -235,8 +235,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'Unit',
description: '',
editor: standardEditorsRegistry.get('unit').editor as any,
override: standardEditorsRegistry.get('unit').editor as any,
editor: standardEditorsRegistry.get('unit').editor,
override: standardEditorsRegistry.get('unit').editor,
process: stringOverrideProcessor,
settings: {
@ -253,8 +253,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'Field min/max',
description: 'Calculate min max per field',
editor: standardEditorsRegistry.get('boolean').editor as any,
override: standardEditorsRegistry.get('boolean').editor as any,
editor: standardEditorsRegistry.get('boolean').editor,
override: standardEditorsRegistry.get('boolean').editor,
process: booleanOverrideProcessor,
shouldApply: (field) => field.type === FieldType.number,
@ -270,8 +270,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'Min',
description: 'Leave empty to calculate based on all values',
editor: standardEditorsRegistry.get('number').editor as any,
override: standardEditorsRegistry.get('number').editor as any,
editor: standardEditorsRegistry.get('number').editor,
override: standardEditorsRegistry.get('number').editor,
process: numberOverrideProcessor,
settings: {
@ -287,8 +287,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'Max',
description: 'Leave empty to calculate based on all values',
editor: standardEditorsRegistry.get('number').editor as any,
override: standardEditorsRegistry.get('number').editor as any,
editor: standardEditorsRegistry.get('number').editor,
override: standardEditorsRegistry.get('number').editor,
process: numberOverrideProcessor,
settings: {
@ -304,8 +304,8 @@ export const getAllStandardFieldConfigs = () => {
path: 'decimals',
name: 'Decimals',
editor: standardEditorsRegistry.get('number').editor as any,
override: standardEditorsRegistry.get('number').editor as any,
editor: standardEditorsRegistry.get('number').editor,
override: standardEditorsRegistry.get('number').editor,
process: numberOverrideProcessor,
settings: {
@ -325,8 +325,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'No value',
description: 'What to show when there is no value',
editor: standardEditorsRegistry.get('text').editor as any,
override: standardEditorsRegistry.get('text').editor as any,
editor: standardEditorsRegistry.get('text').editor,
override: standardEditorsRegistry.get('text').editor,
process: stringOverrideProcessor,
settings: {
@ -341,8 +341,8 @@ export const getAllStandardFieldConfigs = () => {
id: 'links',
path: 'links',
name: 'Data links',
editor: standardEditorsRegistry.get('links').editor as any,
override: standardEditorsRegistry.get('links').editor as any,
editor: standardEditorsRegistry.get('links').editor,
override: standardEditorsRegistry.get('links').editor,
process: dataLinksOverrideProcessor,
settings: {
placeholder: '-',
@ -356,8 +356,8 @@ export const getAllStandardFieldConfigs = () => {
id: 'color',
path: 'color',
name: 'Color scheme',
editor: standardEditorsRegistry.get('fieldColor').editor as any,
override: standardEditorsRegistry.get('fieldColor').editor as any,
editor: standardEditorsRegistry.get('fieldColor').editor,
override: standardEditorsRegistry.get('fieldColor').editor,
process: identityOverrideProcessor,
shouldApply: () => true,
settings: {
@ -373,8 +373,8 @@ export const getAllStandardFieldConfigs = () => {
name: 'Value mappings',
description: 'Modify the display text based on input value',
editor: standardEditorsRegistry.get('mappings').editor as any,
override: standardEditorsRegistry.get('mappings').editor as any,
editor: standardEditorsRegistry.get('mappings').editor,
override: standardEditorsRegistry.get('mappings').editor,
process: valueMappingsOverrideProcessor,
settings: {},
defaultValue: [],
@ -387,8 +387,8 @@ export const getAllStandardFieldConfigs = () => {
id: 'thresholds',
path: 'thresholds',
name: 'Thresholds',
editor: standardEditorsRegistry.get('thresholds').editor as any,
override: standardEditorsRegistry.get('thresholds').editor as any,
editor: standardEditorsRegistry.get('thresholds').editor,
override: standardEditorsRegistry.get('thresholds').editor,
process: thresholdsOverrideProcessor,
settings: {},
defaultValue: {
@ -408,8 +408,8 @@ export const getAllStandardFieldConfigs = () => {
path: 'filterable',
name: 'Ad-hoc filterable',
hideFromDefaults: true,
editor: standardEditorsRegistry.get('boolean').editor as any,
override: standardEditorsRegistry.get('boolean').editor as any,
editor: standardEditorsRegistry.get('boolean').editor,
override: standardEditorsRegistry.get('boolean').editor,
process: booleanOverrideProcessor,
shouldApply: () => true,
settings: {},

View File

@ -1,6 +1,6 @@
import React from 'react';
import { FieldConfigEditorProps, SelectFieldConfigSettings, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectFieldConfigSettings, SelectableValue } from '@grafana/data';
import { Select } from '@grafana/ui';
interface State<T> {
@ -8,7 +8,7 @@ interface State<T> {
options: Array<SelectableValue<T>>;
}
type Props<T> = FieldConfigEditorProps<T, SelectFieldConfigSettings<T>>;
type Props<T> = StandardEditorProps<T, SelectFieldConfigSettings<T>>;
export class SelectValueEditor<T> extends React.PureComponent<Props<T>, State<T>> {
state: State<T> = {

View File

@ -3,13 +3,13 @@ import { Global } from '@emotion/react';
import Slider from 'rc-slider';
import React, { useCallback, useEffect, useRef, useState } from 'react';
import { FieldConfigEditorProps, GrafanaTheme2, SliderFieldConfigSettings } from '@grafana/data';
import { StandardEditorProps, GrafanaTheme2, SliderFieldConfigSettings } from '@grafana/data';
import { useTheme2 } from '@grafana/ui';
import { getStyles } from '@grafana/ui/src/components/Slider/styles';
import { NumberInput } from './NumberInput';
type Props = FieldConfigEditorProps<number, SliderFieldConfigSettings>;
type Props = StandardEditorProps<number, SliderFieldConfigSettings>;
export const SliderValueEditor = ({ value, onChange, item }: Props) => {
// Input reference

View File

@ -1,6 +1,6 @@
import React from 'react';
import { FieldConfigEditorProps, StatsPickerConfigSettings } from '@grafana/data';
import { StandardEditorProps, StatsPickerConfigSettings } from '@grafana/data';
import { StatsPicker } from '@grafana/ui';
export const StatsPickerEditor = ({
@ -8,7 +8,7 @@ export const StatsPickerEditor = ({
onChange,
item,
id,
}: FieldConfigEditorProps<string[], StatsPickerConfigSettings>) => {
}: StandardEditorProps<string[], StatsPickerConfigSettings>) => {
return (
<StatsPicker
stats={value}

View File

@ -1,11 +1,11 @@
import { css } from '@emotion/css';
import React from 'react';
import { FieldConfigEditorProps, StringFieldConfigSettings, GrafanaTheme2 } from '@grafana/data';
import { StandardEditorProps, StringFieldConfigSettings, GrafanaTheme2 } from '@grafana/data';
import { config } from '@grafana/runtime';
import { stylesFactory, Button, Icon, Input } from '@grafana/ui';
type Props = FieldConfigEditorProps<string[], StringFieldConfigSettings>;
type Props = StandardEditorProps<string[], StringFieldConfigSettings>;
interface State {
showAdd: boolean;
}

View File

@ -1,10 +1,10 @@
import { css } from '@emotion/css';
import React from 'react';
import { FieldConfigEditorProps, GrafanaTheme2, UnitFieldConfigSettings } from '@grafana/data';
import { StandardEditorProps, GrafanaTheme2, UnitFieldConfigSettings } from '@grafana/data';
import { IconButton, UnitPicker, useStyles2 } from '@grafana/ui';
type Props = FieldConfigEditorProps<string, UnitFieldConfigSettings>;
type Props = StandardEditorProps<string, UnitFieldConfigSettings>;
export function UnitValueEditor({ value, onChange, item }: Props) {
const styles = useStyles2(getStyles);

View File

@ -1,13 +1,13 @@
import React from 'react';
import { FieldConfigEditorProps, ThresholdsConfig, ThresholdsMode, ThresholdsFieldConfigSettings } from '@grafana/data';
import { StandardEditorProps, ThresholdsConfig, ThresholdsMode, ThresholdsFieldConfigSettings } from '@grafana/data';
import { ThresholdsEditor } from './ThresholdsEditor';
export class ThresholdsValueEditor extends React.PureComponent<
FieldConfigEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>
> {
constructor(props: FieldConfigEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>) {
type Props = StandardEditorProps<ThresholdsConfig, ThresholdsFieldConfigSettings>;
export class ThresholdsValueEditor extends React.PureComponent<Props> {
constructor(props: Props) {
super(props);
}

View File

@ -30,8 +30,8 @@ export const plugin = new PanelPlugin<Options, GraphFieldConfig>(HeatmapPanel)
path: 'scaleDistribution',
name: 'Y axis scale',
category: ['Heatmap'],
editor: ScaleDistributionEditor as any,
override: ScaleDistributionEditor as any,
editor: ScaleDistributionEditor,
override: ScaleDistributionEditor,
defaultValue: { type: ScaleDistribution.Linear },
shouldApply: (f) => f.type === FieldType.number,
process: identityOverrideProcessor,

View File

@ -47,7 +47,6 @@ export const ArcOptionsEditor = ({ value, onChange, context }: ArcOptionsEditorP
},
id: `arc-field-${i}`,
name: `arc-field-${i}`,
editor: () => null,
}}
/>
<ColorPicker

View File

@ -1,6 +1,6 @@
import React from 'react';
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectableValue } from '@grafana/data';
import { HorizontalGroup, RadioButtonGroup } from '@grafana/ui';
import { InputPrefix, NullsThresholdInput } from './NullsThresholdInput';
@ -16,7 +16,7 @@ const DISCONNECT_OPTIONS: Array<SelectableValue<boolean | number>> = [
},
];
type Props = FieldOverrideEditorProps<boolean | number, unknown>;
type Props = StandardEditorProps<boolean | number, { isTime: boolean }>;
export const InsertNullsEditor = ({ value, onChange, item }: Props) => {
const isThreshold = typeof value === 'number';
@ -30,7 +30,7 @@ export const InsertNullsEditor = ({ value, onChange, item }: Props) => {
value={value}
onChange={onChange}
inputPrefix={InputPrefix.GreaterThan}
isTime={item.settings.isTime}
isTime={item.settings?.isTime ?? false}
/>
)}
</HorizontalGroup>

View File

@ -1,6 +1,6 @@
import React, { useMemo } from 'react';
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectableValue } from '@grafana/data';
import { LineStyle } from '@grafana/schema';
import { HorizontalGroup, IconButton, RadioButtonGroup, Select } from '@grafana/ui';
@ -52,7 +52,7 @@ const dotOptions: Array<SelectableValue<string>> = [
value: txt,
}));
type Props = FieldOverrideEditorProps<LineStyle, unknown>;
type Props = StandardEditorProps<LineStyle, unknown>;
export const LineStyleEditor = ({ value, onChange }: Props) => {
const options = useMemo(() => (value?.fill === 'dash' ? dashOptions : dotOptions), [value]);

View File

@ -1,6 +1,6 @@
import React from 'react';
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectableValue } from '@grafana/data';
import { HorizontalGroup, RadioButtonGroup } from '@grafana/ui';
import { InputPrefix, NullsThresholdInput } from './NullsThresholdInput';
@ -20,7 +20,7 @@ const GAPS_OPTIONS: Array<SelectableValue<boolean | number>> = [
},
];
type Props = FieldOverrideEditorProps<boolean | number, unknown>;
type Props = StandardEditorProps<boolean | number, { isTime: boolean }>;
export const SpanNullsEditor = ({ value, onChange, item }: Props) => {
const isThreshold = typeof value === 'number';
@ -34,7 +34,7 @@ export const SpanNullsEditor = ({ value, onChange, item }: Props) => {
value={value}
onChange={onChange}
inputPrefix={InputPrefix.LessThan}
isTime={item.settings.isTime}
isTime={item.settings?.isTime ?? false}
/>
)}
</HorizontalGroup>

View File

@ -1,10 +1,13 @@
import React, { useCallback } from 'react';
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data';
import { StandardEditorProps, SelectableValue } from '@grafana/data';
import { GraphTresholdsStyleMode } from '@grafana/schema';
import { Select } from '@grafana/ui';
type Props = FieldOverrideEditorProps<SelectableValue<{ mode: GraphTresholdsStyleMode }>, unknown>;
type Props = StandardEditorProps<
SelectableValue<{ mode: GraphTresholdsStyleMode }>,
{ options: Array<SelectableValue<GraphTresholdsStyleMode>> }
>;
export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
const onChangeCb = useCallback(
@ -15,5 +18,5 @@ export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
},
[onChange]
);
return <Select inputId={id} value={value.mode} options={item.settings.options} onChange={onChangeCb} />;
return <Select inputId={id} value={value.mode} options={item.settings?.options ?? []} onChange={onChangeCb} />;
};