import React from 'react';
import useAsync from 'react-use/lib/useAsync';
import { InlineLabel } from '@grafana/ui';
import { LokiQueryField } from '../loki/components/LokiQueryField';
import { LokiDatasource } from '../loki/datasource';
import { LokiQuery } from '../loki/types';
import { TempoQuery } from './types';
import { getDS } from './utils';
interface LokiSearchProps {
logsDatasourceUid?: string;
onChange: (value: LokiQuery) => void;
onRunQuery: () => void;
query: TempoQuery;
}
export function LokiSearch({ logsDatasourceUid, onChange, onRunQuery, query }: LokiSearchProps) {
const dsState = useAsync(() => getDS(logsDatasourceUid), [logsDatasourceUid]);
if (dsState.loading) {
return null;
}
const ds = dsState.value as LokiDatasource;
if (ds) {
return (
<>