import { css } from '@emotion/css'; import React from 'react'; import { QueryEditorProps } from '@grafana/data'; import { FileDropzone, InlineField, InlineFieldRow, QueryField, RadioButtonGroup, useTheme2 } from '@grafana/ui'; import { JaegerDatasource } from '../datasource'; import { JaegerQuery, JaegerQueryType } from '../types'; import { SearchForm } from './SearchForm'; type Props = QueryEditorProps; export function QueryEditor({ datasource, query, onChange, onRunQuery }: Props) { const theme = useTheme2(); const onChangeQuery = (value: string) => { const nextQuery: JaegerQuery = { ...query, query: value }; onChange(nextQuery); }; const renderEditorBody = () => { switch (query.queryType) { case 'search': return ; case 'upload': return (
{ datasource.uploadedJson = result; onRunQuery(); }} />
); default: return ( {}} placeholder={'Enter a Trace ID (run with Shift+Enter)'} portalOrigin="jaeger" /> ); } }; return ( <>
options={[ { value: 'search', label: 'Search' }, { value: undefined, label: 'TraceID' }, { value: 'upload', label: 'JSON file' }, ]} value={query.queryType} onChange={(v) => onChange({ ...query, queryType: v, }) } size="md" /> {renderEditorBody()}
); }