import React, { ChangeEvent } from 'react'; import { QueryEditorProps } from '@grafana/data'; import { EditorField, EditorHeader, EditorRow, InlineSelect, Space, EditorSwitch } from '@grafana/experimental'; import { Alert, Input } from '@grafana/ui'; import { CloudWatchDatasource } from '../datasource'; import { isCloudWatchAnnotationQuery } from '../guards'; import { useRegions } from '../hooks'; import { CloudWatchJsonData, CloudWatchQuery, MetricStat } from '../types'; import { MetricStatEditor } from './MetricStatEditor'; export type Props = QueryEditorProps; export const AnnotationQueryEditor = (props: Props) => { const { query, onChange, datasource } = props; const [regions, regionIsLoading] = useRegions(datasource); if (!isCloudWatchAnnotationQuery(query)) { return ( {JSON.stringify(query, null, 4)} ); } return ( <> v.value === query.region)} placeholder="Select region" allowCustomValue onChange={({ value: region }) => region && onChange({ ...query, region })} options={regions} isLoading={regionIsLoading} /> onChange({ ...query, ...metricStat })} onRunQuery={() => {}} > ) => onChange({ ...query, period: event.target.value })} /> { onChange({ ...query, prefixMatching: e.currentTarget.checked, }); }} /> ) => onChange({ ...query, actionPrefix: event.target.value }) } /> ) => onChange({ ...query, alarmNamePrefix: event.target.value }) } /> ); };