grafana/public/app/plugins/datasource/tempo/LokiSearch.tsx
Andre Pereira bd59a27b99
Tempo: Remove traceqlSearch feature toggle (#72029)
* Remove feature flag from registry.go

* Remove usages of toggle

* Refactor and cleanup Tempo's query field components

* Added deprecation alert

* Mark nativeSearch fields as deprecated

* Also show deprecated search tab if queryType is nativeSearch

* Update deprecation message to list grafana version

* Fix merge conflict

* Remove mention of toggle from docs
2023-07-24 16:26:10 +01:00

58 lines
1.5 KiB
TypeScript

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 (
<>
<InlineLabel>Tempo uses {ds.name} to find traces.</InlineLabel>
<LokiQueryField
datasource={ds}
onChange={onChange}
onRunQuery={onRunQuery}
query={query.linkedQuery ?? ({ refId: 'linked' } as LokiQuery)}
history={[]}
/>
</>
);
}
if (!logsDatasourceUid) {
return <div className="text-warning">Please set up a Loki search datasource in the datasource settings.</div>;
}
if (logsDatasourceUid && !ds) {
return (
<div className="text-warning">
Loki search datasource is configured but the data source no longer exists. Please configure existing data source
to use the search.
</div>
);
}
return null;
}