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.", "8"],
[0, 0, 0, "Unexpected any. Specify a different type.", "9"], [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.", "10"],
[0, 0, 0, "Unexpected any. Specify a different type.", "11"], [0, 0, 0, "Unexpected any. Specify a different type.", "11"]
[0, 0, 0, "Unexpected any. Specify a different type.", "12"]
], ],
"packages/grafana-data/src/types/flot.ts:5381": [ "packages/grafana-data/src/types/flot.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "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.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"], [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, "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, "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, "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, "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, "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, "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, "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.", "17"],
[0, 0, 0, "Unexpected any. Specify a different type.", "18"], [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, "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.", "22"],
[0, 0, 0, "Unexpected any. Specify a different type.", "23"], [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, "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.", "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"]
], ],
"packages/grafana-data/src/utils/Registry.ts:5381": [ "packages/grafana-data/src/utils/Registry.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "packages/grafana-ui/src/options/builder/hideSeries.tsx:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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": [ "packages/grafana-ui/src/slate-plugins/braces.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"] [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"] [0, 0, 0, "Styles should be written using objects.", "0"]
], ],
"public/app/core/components/OptionsUI/registry.tsx:5381": [ "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, "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, "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, "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, "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, "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.", "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"]
], ],
"public/app/core/components/PageHeader/PageHeader.tsx:5381": [ "public/app/core/components/PageHeader/PageHeader.tsx:5381": [
[0, 0, 0, "Styles should be written using objects.", "0"], [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": [ "public/app/plugins/panel/heatmap/migrations.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"] [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": [ "public/app/plugins/panel/heatmap/palettes.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"], [0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Unexpected any. Specify a different type.", "1"] [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> { export interface StandardEditorProps<TValue = any, TSettings = any, TOptions = any, TState = any> {
value: TValue; value: TValue;
onChange: (value?: TValue) => void; onChange: (value?: TValue) => void;
item: StandardEditorsRegistryItem<TValue, TSettings>;
context: StandardEditorContext<TOptions, TState>; context: StandardEditorContext<TOptions, TState>;
id?: string; id?: string;
item: RegistryItem & {
settings?: TSettings;
};
} }
export interface StandardEditorsRegistryItem<TValue = any, TSettings = any> extends RegistryItem { export interface StandardEditorsRegistryItem<TValue = any, TSettings = any> extends RegistryItem {
editor: ComponentType<StandardEditorProps<TValue, TSettings>>; editor: ComponentType<StandardEditorProps<TValue, TSettings>>;
settings?: TSettings; settings?: TSettings;

View File

@ -73,18 +73,12 @@ export interface FieldOverrideContext extends StandardEditorContext<any, any> {
field?: Field; field?: Field;
dataFrameIndex?: number; // The index for the selected field frame 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'> { /** @deprecated Use StandardEditorProps instead */
item: FieldConfigPropertyItem<TValue, TSettings>; export type FieldConfigEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;
context: FieldOverrideContext;
} /** @deprecated Use StandardEditorProps instead */
export type FieldOverrideEditorProps<TValue, TSettings extends {}> = StandardEditorProps<TValue, TSettings>;
export interface FieldConfigEditorConfig<TOptions, TSettings = any, TValue = any> export interface FieldConfigEditorConfig<TOptions, TSettings = any, TValue = any>
extends OptionEditorConfig<TOptions, TSettings, TValue> { 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> 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) // 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 */ /** true for plugin field config properties */
isCustom?: boolean; isCustom?: boolean;

View File

@ -18,7 +18,7 @@ import {
import { PanelOptionsSupplier } from '../panel/PanelPlugin'; import { PanelOptionsSupplier } from '../panel/PanelPlugin';
import { isObject } from '../types'; import { isObject } from '../types';
import { OptionsEditorItem, OptionsUIRegistryBuilder } from '../types/OptionsUIRegistryBuilder'; 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'; import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel';
/** /**
@ -26,15 +26,15 @@ import { PanelOptionsEditorConfig, PanelOptionsEditorItem } from '../types/panel
*/ */
export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder< export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder<
TOptions, TOptions,
FieldConfigEditorProps<any, any>, StandardEditorProps<any, any>,
FieldConfigPropertyItem<TOptions> FieldConfigPropertyItem<TOptions>
> { > {
addNumberInput<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings & NumberFieldConfigSettings, number>) { addNumberInput<TSettings>(config: FieldConfigEditorConfig<TOptions, TSettings & NumberFieldConfigSettings, number>) {
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
override: standardEditorsRegistry.get('number').editor as any, override: standardEditorsRegistry.get('number').editor,
editor: standardEditorsRegistry.get('number').editor as any, editor: standardEditorsRegistry.get('number').editor,
process: numberOverrideProcessor, process: numberOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true), shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {}, settings: config.settings || {},
@ -45,8 +45,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
override: standardEditorsRegistry.get('slider').editor as any, override: standardEditorsRegistry.get('slider').editor,
editor: standardEditorsRegistry.get('slider').editor as any, editor: standardEditorsRegistry.get('slider').editor,
process: numberOverrideProcessor, process: numberOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true), shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {}, settings: config.settings || {},
@ -57,8 +57,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
override: standardEditorsRegistry.get('text').editor as any, override: standardEditorsRegistry.get('text').editor,
editor: standardEditorsRegistry.get('text').editor as any, editor: standardEditorsRegistry.get('text').editor,
process: stringOverrideProcessor, process: stringOverrideProcessor,
shouldApply: config.shouldApply ?? (() => true), shouldApply: config.shouldApply ?? (() => true),
settings: config.settings || {}, settings: config.settings || {},
@ -71,8 +71,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
override: standardEditorsRegistry.get('select').editor as any, override: standardEditorsRegistry.get('select').editor,
editor: standardEditorsRegistry.get('select').editor as any, editor: standardEditorsRegistry.get('select').editor,
process: selectOverrideProcessor, process: selectOverrideProcessor,
// ??? // ???
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
@ -84,8 +84,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
override: standardEditorsRegistry.get('radio').editor as any, override: standardEditorsRegistry.get('radio').editor,
editor: standardEditorsRegistry.get('radio').editor as any, editor: standardEditorsRegistry.get('radio').editor,
process: selectOverrideProcessor, process: selectOverrideProcessor,
// ??? // ???
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
@ -97,8 +97,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('boolean').editor as any, editor: standardEditorsRegistry.get('boolean').editor,
override: standardEditorsRegistry.get('boolean').editor as any, override: standardEditorsRegistry.get('boolean').editor,
process: booleanOverrideProcessor, process: booleanOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {}, settings: config.settings || {},
@ -109,8 +109,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('color').editor as any, editor: standardEditorsRegistry.get('color').editor,
override: standardEditorsRegistry.get('color').editor as any, override: standardEditorsRegistry.get('color').editor,
process: identityOverrideProcessor, process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {}, settings: config.settings || {},
@ -123,8 +123,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('unit').editor as any, editor: standardEditorsRegistry.get('unit').editor,
override: standardEditorsRegistry.get('unit').editor as any, override: standardEditorsRegistry.get('unit').editor,
process: unitOverrideProcessor, process: unitOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {}, settings: config.settings || {},
@ -137,8 +137,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('field-name').editor as any, editor: standardEditorsRegistry.get('field-name').editor,
override: standardEditorsRegistry.get('field-name').editor as any, override: standardEditorsRegistry.get('field-name').editor,
process: identityOverrideProcessor, process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {}, settings: config.settings || {},
@ -152,8 +152,8 @@ export class FieldConfigEditorBuilder<TOptions> extends OptionsUIRegistryBuilder
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: editor as any, editor: editor,
override: editor as any, override: editor,
process: identityOverrideProcessor, process: identityOverrideProcessor,
shouldApply: config.shouldApply ? config.shouldApply : () => true, shouldApply: config.shouldApply ? config.shouldApply : () => true,
settings: config.settings || {}, settings: config.settings || {},
@ -226,7 +226,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('color').editor as any, editor: standardEditorsRegistry.get('color').editor,
settings: config.settings || {}, settings: config.settings || {},
}); });
} }
@ -307,7 +307,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, id: config.path,
editor: standardEditorsRegistry.get('timezone').editor as any, editor: standardEditorsRegistry.get('timezone').editor,
settings: config.settings || {}, settings: config.settings || {},
}); });
} }
@ -318,7 +318,7 @@ export class PanelOptionsEditorBuilder<TOptions> extends OptionsUIRegistryBuilde
return this.addCustomEditor({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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({ return this.addCustomEditor({
...config, ...config,
id: config.path, 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 { startCase } from 'lodash';
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { FieldConfigEditorBuilder, FieldConfigEditorProps } from '@grafana/data'; import { FieldConfigEditorBuilder, StandardEditorProps } from '@grafana/data';
import { HideableFieldConfig, HideSeriesConfig } from '@grafana/schema'; import { HideableFieldConfig, HideSeriesConfig } from '@grafana/schema';
import { FilterPill } from '../../components/FilterPill/FilterPill'; import { FilterPill } from '../../components/FilterPill/FilterPill';
import { HorizontalGroup } from '../../components/Layout/Layout'; import { HorizontalGroup } from '../../components/Layout/Layout';
const SeriesConfigEditor = ({ value, onChange }: FieldConfigEditorProps<HideSeriesConfig, {}>) => { const SeriesConfigEditor = ({ value, onChange }: StandardEditorProps<HideSeriesConfig, {}>) => {
const onChangeToggle = useCallback( const onChangeToggle = useCallback(
(prop: keyof HideSeriesConfig) => { (prop: keyof HideSeriesConfig) => {
onChange({ ...value, [prop]: !value[prop] }); onChange({ ...value, [prop]: !value[prop] });

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,10 +1,13 @@
import React, { useCallback } from 'react'; import React, { useCallback } from 'react';
import { FieldOverrideEditorProps, SelectableValue } from '@grafana/data'; import { StandardEditorProps, SelectableValue } from '@grafana/data';
import { GraphTresholdsStyleMode } from '@grafana/schema'; import { GraphTresholdsStyleMode } from '@grafana/schema';
import { Select } from '@grafana/ui'; 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) => { export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
const onChangeCb = useCallback( const onChangeCb = useCallback(
@ -15,5 +18,5 @@ export const ThresholdsStyleEditor = ({ item, value, onChange, id }: Props) => {
}, },
[onChange] [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} />;
}; };