Files
grafana/public/app/plugins/datasource/tempo/traceql/QueryEditor.tsx
Andre Pereira 8bf914ac0b Tempo: Fix service graph menu item links (#75748)
* 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
2023-10-09 14:22:39 +01:00

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;
`,
});