// Core Grafana history https://github.com/grafana/grafana/blob/v11.0.0-preview/public/app/plugins/datasource/prometheus/components/AnnotationQueryEditor.tsx import { memo } from 'react'; import { AnnotationQuery } from '@grafana/data'; import { selectors } from '@grafana/e2e-selectors'; import { Trans, t } from '@grafana/i18n'; import { EditorField, EditorRow, EditorRows, EditorSwitch } from '@grafana/plugin-ui'; import { AutoSizeInput, Input, Space } from '@grafana/ui'; import { PromQueryCodeEditor } from '../querybuilder/components/PromQueryCodeEditor'; import { PromQuery } from '../types'; import { PromQueryEditorProps } from './types'; type Props = PromQueryEditorProps & { annotation?: AnnotationQuery; onAnnotationChange?: (annotation: AnnotationQuery) => void; }; const PLACEHOLDER_TITLE = '{{alertname}}'; const PLACEHOLDER_TEXT = '{{instance}}'; const PLACEHOLDER_TAGS = 'label1,label2'; /** * AnnotationQueryEditor component for Prometheus datasource. * Allows users to configure annotation queries with options for title, tags, text format, * and timestamp settings. */ export const AnnotationQueryEditor = memo(function AnnotationQueryEditor(props: Props) { const { annotation, onAnnotationChange, onChange, onRunQuery, query } = props; if (!annotation || !onAnnotationChange) { return (

Annotation data load error!

); } const handleMinStepChange = (value: string) => { onChange({ ...query, interval: value }); }; const handleTitleChange = (value: string) => { onAnnotationChange({ ...annotation, titleFormat: value, }); }; const handleTagsChange = (value: string) => { onAnnotationChange({ ...annotation, tagKeys: value, }); }; const handleTextChange = (value: string) => { onAnnotationChange({ ...annotation, textFormat: value, }); }; const handleUseValueForTimeChange = (checked: boolean) => { onAnnotationChange({ ...annotation, useValueForTime: checked, }); }; return ( <> An additional lower limit for the step parameter of the Prometheus query and for the{' '} {'{{intervalVar}}'} and {'{{rateIntervalVar}}'} variables. } > handleMinStepChange(e.currentTarget.value)} id={selectors.components.DataSource.Prometheus.annotations.minStep} data-testid={selectors.components.DataSource.Prometheus.annotations.minStep} /> handleTitleChange(event.currentTarget.value)} data-testid={selectors.components.DataSource.Prometheus.annotations.title} /> handleTagsChange(event.currentTarget.value)} data-testid={selectors.components.DataSource.Prometheus.annotations.tags} /> handleTextChange(event.currentTarget.value)} data-testid={selectors.components.DataSource.Prometheus.annotations.text} /> handleUseValueForTimeChange(event.currentTarget.checked)} data-testid={selectors.components.DataSource.Prometheus.annotations.seriesValueAsTimestamp} /> ); });