Tempo: Basic PoC of the upcoming TraceQL editor in Explore (#54028)

* First working version of the TraceQL editor with syntax highlighting and autocomplete

* Add feature flag around the new editor option

* Fix tests and cleanup

* Fix misspelling
This commit is contained in:
Andre Pereira
2022-08-24 17:57:59 +01:00
committed by GitHub
parent 94b4f6f459
commit c8f2148f75
12 changed files with 687 additions and 9 deletions

View File

@@ -1,6 +1,6 @@
import { Value } from 'slate';
import { HistoryItem, LanguageProvider, SelectableValue } from '@grafana/data';
import { LanguageProvider, SelectableValue } from '@grafana/data';
import { CompletionItemGroup, TypeaheadInput, TypeaheadOutput } from '@grafana/ui';
import { TempoDatasource } from './datasource';
@@ -21,8 +21,13 @@ export default class TempoLanguageProvider extends LanguageProvider {
};
start = async () => {
await this.fetchTags();
return [];
if (!this.startTask) {
this.startTask = this.fetchTags().then(() => {
return [];
});
}
return this.startTask;
};
async fetchTags() {
@@ -30,10 +35,11 @@ export default class TempoLanguageProvider extends LanguageProvider {
this.tags = response.tagNames;
}
provideCompletionItems = async (
{ prefix, text, value, labelKey, wrapperClasses }: TypeaheadInput,
context: { history: Array<HistoryItem<any>> } = { history: [] }
): Promise<TypeaheadOutput> => {
getTags = () => {
return this.tags;
};
provideCompletionItems = async ({ text, value }: TypeaheadInput): Promise<TypeaheadOutput> => {
const emptyResult: TypeaheadOutput = { suggestions: [] };
if (!value) {