diff --git a/.betterer.results b/.betterer.results index 9d7bce2be57..b33c8a5678c 100644 --- a/.betterer.results +++ b/.betterer.results @@ -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"] diff --git a/packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts b/packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts index 75f0a32f94d..6f8beee78ae 100644 --- a/packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts +++ b/packages/grafana-data/src/field/standardFieldConfigEditorRegistry.ts @@ -19,10 +19,14 @@ export interface StandardEditorContext { export interface StandardEditorProps { value: TValue; onChange: (value?: TValue) => void; - item: StandardEditorsRegistryItem; context: StandardEditorContext; id?: string; + + item: RegistryItem & { + settings?: TSettings; + }; } + export interface StandardEditorsRegistryItem extends RegistryItem { editor: ComponentType>; settings?: TSettings; diff --git a/packages/grafana-data/src/types/fieldOverrides.ts b/packages/grafana-data/src/types/fieldOverrides.ts index 8a3a9bf15d0..dad3547523c 100644 --- a/packages/grafana-data/src/types/fieldOverrides.ts +++ b/packages/grafana-data/src/types/fieldOverrides.ts @@ -73,18 +73,12 @@ export interface FieldOverrideContext extends StandardEditorContext { field?: Field; dataFrameIndex?: number; // The index for the selected field frame } -export interface FieldConfigEditorProps - extends Omit, 'item'> { - item: FieldConfigPropertyItem; // The property info - value: TValue; - context: FieldOverrideContext; - onChange: (value?: TValue) => void; -} -export interface FieldOverrideEditorProps extends Omit, 'item'> { - item: FieldConfigPropertyItem; - context: FieldOverrideContext; -} +/** @deprecated Use StandardEditorProps instead */ +export type FieldConfigEditorProps = StandardEditorProps; + +/** @deprecated Use StandardEditorProps instead */ +export type FieldOverrideEditorProps = StandardEditorProps; export interface FieldConfigEditorConfig extends OptionEditorConfig { @@ -102,9 +96,9 @@ export interface FieldConfigEditorConfig - extends OptionsEditorItem, TValue> { + extends OptionsEditorItem, TValue> { // An editor that can be filled in with context info (template variables etc) - override: ComponentType>; + override: ComponentType>; /** true for plugin field config properties */ isCustom?: boolean; diff --git a/packages/grafana-data/src/utils/OptionsUIBuilders.ts b/packages/grafana-data/src/utils/OptionsUIBuilders.ts index 29beeb9580f..0743f1008e1 100644 --- a/packages/grafana-data/src/utils/OptionsUIBuilders.ts +++ b/packages/grafana-data/src/utils/OptionsUIBuilders.ts @@ -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 extends OptionsUIRegistryBuilder< TOptions, - FieldConfigEditorProps, + StandardEditorProps, FieldConfigPropertyItem > { addNumberInput(config: FieldConfigEditorConfig) { 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 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 }); } } diff --git a/packages/grafana-ui/src/options/builder/hideSeries.tsx b/packages/grafana-ui/src/options/builder/hideSeries.tsx index a70dfe74885..90ae2deb6c5 100644 --- a/packages/grafana-ui/src/options/builder/hideSeries.tsx +++ b/packages/grafana-ui/src/options/builder/hideSeries.tsx @@ -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) => { +const SeriesConfigEditor = ({ value, onChange }: StandardEditorProps) => { const onChangeToggle = useCallback( (prop: keyof HideSeriesConfig) => { onChange({ ...value, [prop]: !value[prop] }); diff --git a/packages/grafana-ui/src/options/builder/stacking.tsx b/packages/grafana-ui/src/options/builder/stacking.tsx index 7ab189c398e..5d561c824a2 100644 --- a/packages/grafana-ui/src/options/builder/stacking.tsx +++ b/packages/grafana-ui/src/options/builder/stacking.tsx @@ -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) => { +export const StackingEditor = ({ + value, + context, + onChange, + item, +}: StandardEditorProps> }>) => { return ( { onChange({ ...value, diff --git a/public/app/core/components/OptionsUI/fieldColor.tsx b/public/app/core/components/OptionsUI/fieldColor.tsx index da1294e6d2f..bfd8c480bcb 100644 --- a/public/app/core/components/OptionsUI/fieldColor.tsx +++ b/public/app/core/components/OptionsUI/fieldColor.tsx @@ -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; +type Props = StandardEditorProps; export const FieldColorEditor = ({ value, onChange, item, id }: Props) => { const theme = useTheme2(); diff --git a/public/app/core/components/OptionsUI/links.tsx b/public/app/core/components/OptionsUI/links.tsx index fe5baf07a0b..31aa70e266a 100644 --- a/public/app/core/components/OptionsUI/links.tsx +++ b/public/app/core/components/OptionsUI/links.tsx @@ -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; +type Props = StandardEditorProps; export const DataLinksValueEditor = ({ value, onChange, context }: Props) => { return ( diff --git a/public/app/core/components/OptionsUI/multiSelect.tsx b/public/app/core/components/OptionsUI/multiSelect.tsx index 80f30019e65..9550e352f4f 100644 --- a/public/app/core/components/OptionsUI/multiSelect.tsx +++ b/public/app/core/components/OptionsUI/multiSelect.tsx @@ -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 { @@ -8,7 +8,7 @@ interface State { options: Array>; } -type Props = FieldConfigEditorProps>; +type Props = StandardEditorProps>; /** * MultiSelect for options UI diff --git a/public/app/core/components/OptionsUI/number.tsx b/public/app/core/components/OptionsUI/number.tsx index 7f5e6366dc5..ff57e1e0c1e 100644 --- a/public/app/core/components/OptionsUI/number.tsx +++ b/public/app/core/components/OptionsUI/number.tsx @@ -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; +type Props = StandardEditorProps; export const NumberValueEditor = ({ value, onChange, item }: Props) => { const { settings } = item; diff --git a/public/app/core/components/OptionsUI/registry.tsx b/public/app/core/components/OptionsUI/registry.tsx index 2a3f6c65f4d..dfe87a79436 100644 --- a/public/app/core/components/OptionsUI/registry.tsx +++ b/public/app/core/components/OptionsUI/registry.tsx @@ -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 = { id: 'slider', name: 'Slider', description: 'Allows numeric values input', - editor: SliderValueEditor as any, + editor: SliderValueEditor, }; const text: StandardEditorsRegistryItem = { @@ -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 = { @@ -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 = { @@ -130,24 +130,24 @@ export const getAllOptionEditors = () => { }, }; - const fieldColor: StandardEditorsRegistryItem = { + const fieldColor: StandardEditorsRegistryItem = { id: 'fieldColor', name: 'Field Color', description: 'Field color selection', - editor: FieldColorEditor as any, + editor: FieldColorEditor, }; const links: StandardEditorsRegistryItem = { id: 'links', name: 'Links', description: 'Allows defining data links', - editor: DataLinksValueEditor as any, + editor: DataLinksValueEditor, }; const statsPicker: StandardEditorsRegistryItem = { 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: {}, diff --git a/public/app/core/components/OptionsUI/select.tsx b/public/app/core/components/OptionsUI/select.tsx index 7a9bd5ce923..006d83cc77b 100644 --- a/public/app/core/components/OptionsUI/select.tsx +++ b/public/app/core/components/OptionsUI/select.tsx @@ -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 { @@ -8,7 +8,7 @@ interface State { options: Array>; } -type Props = FieldConfigEditorProps>; +type Props = StandardEditorProps>; export class SelectValueEditor extends React.PureComponent, State> { state: State = { diff --git a/public/app/core/components/OptionsUI/slider.tsx b/public/app/core/components/OptionsUI/slider.tsx index d06785010cb..e755c00fddd 100644 --- a/public/app/core/components/OptionsUI/slider.tsx +++ b/public/app/core/components/OptionsUI/slider.tsx @@ -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; +type Props = StandardEditorProps; export const SliderValueEditor = ({ value, onChange, item }: Props) => { // Input reference diff --git a/public/app/core/components/OptionsUI/stats.tsx b/public/app/core/components/OptionsUI/stats.tsx index d428b08813b..558d774e9a3 100644 --- a/public/app/core/components/OptionsUI/stats.tsx +++ b/public/app/core/components/OptionsUI/stats.tsx @@ -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) => { +}: StandardEditorProps) => { return ( ; +type Props = StandardEditorProps; interface State { showAdd: boolean; } diff --git a/public/app/core/components/OptionsUI/units.tsx b/public/app/core/components/OptionsUI/units.tsx index d3545045cf2..4bf6d1e653c 100644 --- a/public/app/core/components/OptionsUI/units.tsx +++ b/public/app/core/components/OptionsUI/units.tsx @@ -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; +type Props = StandardEditorProps; export function UnitValueEditor({ value, onChange, item }: Props) { const styles = useStyles2(getStyles); diff --git a/public/app/features/dimensions/editors/ThresholdsEditor/thresholds.tsx b/public/app/features/dimensions/editors/ThresholdsEditor/thresholds.tsx index 1642c083fe1..e89003ba9f9 100644 --- a/public/app/features/dimensions/editors/ThresholdsEditor/thresholds.tsx +++ b/public/app/features/dimensions/editors/ThresholdsEditor/thresholds.tsx @@ -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 -> { - constructor(props: FieldConfigEditorProps) { +type Props = StandardEditorProps; + +export class ThresholdsValueEditor extends React.PureComponent { + constructor(props: Props) { super(props); } diff --git a/public/app/plugins/panel/heatmap/module.tsx b/public/app/plugins/panel/heatmap/module.tsx index a462cf6a52f..0d9b5da6db0 100644 --- a/public/app/plugins/panel/heatmap/module.tsx +++ b/public/app/plugins/panel/heatmap/module.tsx @@ -30,8 +30,8 @@ export const plugin = new PanelPlugin(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, diff --git a/public/app/plugins/panel/nodeGraph/editor/ArcOptionsEditor.tsx b/public/app/plugins/panel/nodeGraph/editor/ArcOptionsEditor.tsx index 11b726a2bb6..1e4427cc398 100644 --- a/public/app/plugins/panel/nodeGraph/editor/ArcOptionsEditor.tsx +++ b/public/app/plugins/panel/nodeGraph/editor/ArcOptionsEditor.tsx @@ -47,7 +47,6 @@ export const ArcOptionsEditor = ({ value, onChange, context }: ArcOptionsEditorP }, id: `arc-field-${i}`, name: `arc-field-${i}`, - editor: () => null, }} /> > = [ }, ]; -type Props = FieldOverrideEditorProps; +type Props = StandardEditorProps; 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} /> )} diff --git a/public/app/plugins/panel/timeseries/LineStyleEditor.tsx b/public/app/plugins/panel/timeseries/LineStyleEditor.tsx index 8ac547d52a3..cd90f9bdcc9 100644 --- a/public/app/plugins/panel/timeseries/LineStyleEditor.tsx +++ b/public/app/plugins/panel/timeseries/LineStyleEditor.tsx @@ -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> = [ value: txt, })); -type Props = FieldOverrideEditorProps; +type Props = StandardEditorProps; export const LineStyleEditor = ({ value, onChange }: Props) => { const options = useMemo(() => (value?.fill === 'dash' ? dashOptions : dotOptions), [value]); diff --git a/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx b/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx index 9912abf383b..5344dc8a528 100644 --- a/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx +++ b/public/app/plugins/panel/timeseries/SpanNullsEditor.tsx @@ -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> = [ }, ]; -type Props = FieldOverrideEditorProps; +type Props = StandardEditorProps; 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} /> )} diff --git a/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx b/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx index 31f4c11a6bf..431ca7094fa 100644 --- a/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx +++ b/public/app/plugins/panel/timeseries/ThresholdsStyleEditor.tsx @@ -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, unknown>; +type Props = StandardEditorProps< + SelectableValue<{ mode: GraphTresholdsStyleMode }>, + { options: Array> } +>; 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 ; };