mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Primarily- moving majority of the types and utils from @grafana/ui to @grafana/data * Move types from grafana-ui to grafana-data * Move valueFormats to grafana-data * Move utils from grafana-ui to grafana-data * Update imports in grafana-ui * revert data's tsconfig change * Update imports in grafana-runtime * Fix import paths in grafana-ui * Move rxjs to devDeps * Core import updates batch 1 * Import updates batch 2 * Imports fix batch 3 * Imports fixes batch i don't know * Fix imorts in grafana-toolkit * Fix imports after master merge
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
// Libraries
|
|
import React, { memo } from 'react';
|
|
|
|
// Types
|
|
import { AbsoluteTimeRange, QueryEditorProps } from '@grafana/data';
|
|
import { LokiDatasource } from '../datasource';
|
|
import { LokiQuery } from '../types';
|
|
import { LokiQueryField } from './LokiQueryField';
|
|
import { useLokiSyntax } from './useLokiSyntax';
|
|
|
|
type Props = QueryEditorProps<LokiDatasource, LokiQuery>;
|
|
|
|
export const LokiQueryEditor = memo(function LokiQueryEditor(props: Props) {
|
|
const { query, data, datasource, onChange, onRunQuery } = props;
|
|
|
|
let absolute: AbsoluteTimeRange;
|
|
if (data && data.request) {
|
|
const { range } = data.request;
|
|
absolute = {
|
|
from: range.from.valueOf(),
|
|
to: range.to.valueOf(),
|
|
};
|
|
} else {
|
|
absolute = {
|
|
from: Date.now() - 10000,
|
|
to: Date.now(),
|
|
};
|
|
}
|
|
|
|
const { isSyntaxReady, setActiveOption, refreshLabels, ...syntaxProps } = useLokiSyntax(
|
|
datasource.languageProvider,
|
|
absolute
|
|
);
|
|
|
|
return (
|
|
<div>
|
|
<LokiQueryField
|
|
datasource={datasource}
|
|
query={query}
|
|
onChange={onChange}
|
|
onRunQuery={onRunQuery}
|
|
history={[]}
|
|
data={data}
|
|
onLoadOptions={setActiveOption}
|
|
onLabelsRefresh={refreshLabels}
|
|
syntaxLoaded={isSyntaxReady}
|
|
absoluteRange={absolute}
|
|
{...syntaxProps}
|
|
/>
|
|
</div>
|
|
);
|
|
});
|
|
|
|
export default LokiQueryEditor;
|