import React from 'react'; import { AnnotationQuery } from '@grafana/data'; import { EditorRow, EditorField, EditorSwitch, Space, EditorRows } from '@grafana/experimental'; import { Input } from '@grafana/ui'; import { PromQueryCodeEditor } from '../querybuilder/components/PromQueryCodeEditor'; import { AutoSizeInput } from '../querybuilder/shared/AutoSizeInput'; import { PromQuery } from '../types'; import { PromQueryEditorProps } from './types'; type Props = PromQueryEditorProps & { annotation?: AnnotationQuery; onAnnotationChange?: (annotation: AnnotationQuery) => void; }; export function AnnotationQueryEditor(props: Props) { // This is because of problematic typing. See AnnotationQueryEditorProps in grafana-data/annotations.ts. const annotation = props.annotation!; const onAnnotationChange = props.onAnnotationChange!; const query = { expr: annotation.expr, refId: annotation.name, interval: annotation.step }; return ( <> { onAnnotationChange({ ...annotation, expr: query.expr, }); }} /> An additional lower limit for the step parameter of the Prometheus query and for the{' '} $__interval and $__rate_interval variables. } > { onAnnotationChange({ ...annotation, step: ev.currentTarget.value, }); }} defaultValue={query.interval} /> { onAnnotationChange({ ...annotation, titleFormat: event.currentTarget.value, }); }} /> { onAnnotationChange({ ...annotation, tagKeys: event.currentTarget.value, }); }} /> { onAnnotationChange({ ...annotation, textFormat: event.currentTarget.value, }); }} /> { onAnnotationChange({ ...annotation, useValueForTime: event.currentTarget.value, }); }} /> ); }