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 ( <> Tempo uses {ds.name} to find traces. ); } if (!logsDatasourceUid) { return
Please set up a Loki search datasource in the datasource settings.
; } if (logsDatasourceUid && !ds) { return (
Loki search datasource is configured but the data source no longer exists. Please configure existing data source to use the search.
); } return null; }