QueryField class

Renders an editor field. Pass initial value as initialQuery and listen to changes in props.onValueChanged. This component can only process strings. Internally it uses Slate Value. Implement props.onTypeahead to use suggestions, see PromQueryField.tsx as an example.

Signature

  1. export declare class QueryField extends React.PureComponent<QueryFieldProps, QueryFieldState>

Import

  1. import { QueryField } from '@grafana/ui';

Constructors

ConstructorModifiersDescription
constructor(props, context)Constructs a new instance of the QueryField class

Properties

PropertyModifiersTypeDescription
editorEditor | null
handleBlur(event: Event, editor: CoreEditor, next: Function) => anyWe need to handle blur events here mainly because of dashboard panels which expect to have query executed on blur.
lastExecutedValueValue | null
mountedboolean
onChange(value: Value, runQuery?: boolean | undefined) => voidUpdate local state, propagate change upstream and optionally run the query afterwards.
pluginsPlugin[]
runOnChange() => void
runOnChangeAndRunQuery() => void
runOnChangeDebouncedFunction
runOnRunQuery() => void

Methods

MethodModifiersDescription
cleanText(text)
componentDidMount()
componentDidUpdate(prevProps, prevState)
componentWillUnmount()
render()

constructor(props, context)

Constructs a new instance of the QueryField class

Signature

  1. constructor(props: QueryFieldProps, context: Context<any>);

Parameters

ParameterTypeDescription
propsQueryFieldProps
contextContext<any>

editor property

Signature

  1. editor: Editor | null;

handleBlur property

We need to handle blur events here mainly because of dashboard panels which expect to have query executed on blur.

Signature

  1. handleBlur: (event: Event, editor: CoreEditor, next: Function) => any;

lastExecutedValue property

Signature

  1. lastExecutedValue: Value | null;

mounted property

Signature

  1. mounted: boolean;

onChange property

Update local state, propagate change upstream and optionally run the query afterwards.

Signature

  1. onChange: (value: Value, runQuery?: boolean | undefined) => void;

plugins property

Signature

  1. plugins: Plugin[];

runOnChange property

Signature

  1. runOnChange: () => void;

runOnChangeAndRunQuery property

Signature

  1. runOnChangeAndRunQuery: () => void;

runOnChangeDebounced property

Signature

  1. runOnChangeDebounced: Function;

runOnRunQuery property

Signature

  1. runOnRunQuery: () => void;

cleanText method

Signature

  1. cleanText(text: string): string;

Parameters

ParameterTypeDescription
textstring

Returns:

string

componentDidMount method

Signature

  1. componentDidMount(): void;

Returns:

void

componentDidUpdate method

Signature

  1. componentDidUpdate(prevProps: QueryFieldProps, prevState: QueryFieldState): void;

Parameters

ParameterTypeDescription
prevPropsQueryFieldProps
prevStateQueryFieldState

Returns:

void

componentWillUnmount method

Signature

  1. componentWillUnmount(): void;

Returns:

void

render method

Signature

  1. render(): JSX.Element;

Returns:

JSX.Element