mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* Only call preventDefault if it exists * Change "View Traces" link to use traceQLSearch instead of the deprecated nativeSearch * Thank you again test. Update tests * Update test * Update betterer * Type fix * Small type change * Update betterer
51 lines
1.5 KiB
TypeScript
51 lines
1.5 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import { defaults } from 'lodash';
|
|
import React from 'react';
|
|
|
|
import { QueryEditorProps } from '@grafana/data';
|
|
import { InlineLabel, useStyles2 } from '@grafana/ui';
|
|
|
|
import { TempoDatasource } from '../datasource';
|
|
import { defaultQuery, MyDataSourceOptions, TempoQuery } from '../types';
|
|
|
|
import { TempoQueryBuilderOptions } from './TempoQueryBuilderOptions';
|
|
import { TraceQLEditor } from './TraceQLEditor';
|
|
|
|
type Props = QueryEditorProps<TempoDatasource, TempoQuery, MyDataSourceOptions>;
|
|
|
|
export function QueryEditor(props: Props) {
|
|
const styles = useStyles2(getStyles);
|
|
const query = defaults(props.query, defaultQuery);
|
|
|
|
const onEditorChange = (value: string) => {
|
|
props.onChange({ ...query, query: value });
|
|
};
|
|
|
|
return (
|
|
<>
|
|
<InlineLabel>
|
|
Build complex queries using TraceQL to select a list of traces.{' '}
|
|
<a rel="noreferrer" target="_blank" href="https://grafana.com/docs/tempo/latest/traceql/">
|
|
Documentation
|
|
</a>
|
|
</InlineLabel>
|
|
<TraceQLEditor
|
|
placeholder="Enter a TraceQL query or trace ID (run with Shift+Enter)"
|
|
value={query.query || ''}
|
|
onChange={onEditorChange}
|
|
datasource={props.datasource}
|
|
onRunQuery={props.onRunQuery}
|
|
/>
|
|
<div className={styles.optionsContainer}>
|
|
<TempoQueryBuilderOptions query={query} onChange={props.onChange} />
|
|
</div>
|
|
</>
|
|
);
|
|
}
|
|
|
|
const getStyles = () => ({
|
|
optionsContainer: css`
|
|
margin-top: 10px;
|
|
`,
|
|
});
|