mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* feat(loki-editor): remove slate and make Monaco the default editor * feat(loki-editor): remove unsupported usages of onBlur * feat(loki-editor): remove monaco feature flag * Chore: remove unused import
58 lines
1.2 KiB
TypeScript
58 lines
1.2 KiB
TypeScript
import { css } from '@emotion/css';
|
|
import React from 'react';
|
|
|
|
import { GrafanaTheme2 } from '@grafana/data';
|
|
import { useStyles2 } from '@grafana/ui';
|
|
|
|
import { testIds } from '../../components/LokiQueryEditor';
|
|
import { LokiQueryField } from '../../components/LokiQueryField';
|
|
import { LokiQueryEditorProps } from '../../components/types';
|
|
|
|
import { LokiQueryBuilderExplained } from './LokiQueryBuilderExplained';
|
|
|
|
type Props = LokiQueryEditorProps & {
|
|
showExplain: boolean;
|
|
};
|
|
|
|
export function LokiQueryCodeEditor({
|
|
query,
|
|
datasource,
|
|
range,
|
|
onRunQuery,
|
|
onChange,
|
|
data,
|
|
app,
|
|
showExplain,
|
|
history,
|
|
}: Props) {
|
|
const styles = useStyles2(getStyles);
|
|
|
|
return (
|
|
<div className={styles.wrapper}>
|
|
<LokiQueryField
|
|
datasource={datasource}
|
|
query={query}
|
|
range={range}
|
|
onRunQuery={onRunQuery}
|
|
onChange={onChange}
|
|
history={history}
|
|
data={data}
|
|
app={app}
|
|
data-testid={testIds.editor}
|
|
/>
|
|
{showExplain && <LokiQueryBuilderExplained query={query.expr} />}
|
|
</div>
|
|
);
|
|
}
|
|
|
|
const getStyles = (theme: GrafanaTheme2) => {
|
|
return {
|
|
wrapper: css`
|
|
max-width: 100%;
|
|
.gf-form {
|
|
margin-bottom: 0.5;
|
|
}
|
|
`,
|
|
};
|
|
};
|