import { css } from '@emotion/css'; import { useState } from 'react'; import { GrafanaTheme2, QueryEditorProps } from '@grafana/data'; import { Box, InlineField, Input, TagsInput, useStyles2 } from '@grafana/ui'; import { GraphiteDatasource } from '../datasource'; import { GraphiteQuery, GraphiteOptions } from '../types'; export const AnnotationEditor = (props: QueryEditorProps) => { const { query, onChange } = props; const [target, setTarget] = useState(query.target ?? ''); const [tags, setTags] = useState(query.tags ?? []); const updateValue = (key: K, val: V) => { if (key === 'tags') { onChange({ ...query, [key]: val, fromAnnotations: true, queryType: key, }); } else { onChange({ ...query, [key]: val, fromAnnotations: true, textEditor: true, }); } }; const onTagsChange = (tagsInput: string[]) => { setTags(tagsInput); updateValue('tags', tagsInput); }; const styles = useStyles2(getStyles); return ( setTarget(e.currentTarget.value || '')} onBlur={() => updateValue('target', target)} placeholder="Example: statsd.application.counters.*.count" />
Or
); }; const getStyles = (theme: GrafanaTheme2) => ({ heading: css({ fontSize: theme.typography.body.fontSize, marginBottom: theme.spacing(1), }), });