mirror of
https://github.com/grafana/grafana.git
synced 2025-01-17 04:02:50 -06:00
Tempo: Provide tag value completion items consistently (#43773)
This commit is contained in:
parent
2b967c4c55
commit
3d6e9076c9
@ -37,7 +37,10 @@ export default class TempoLanguageProvider extends LanguageProvider {
|
||||
if (!value) {
|
||||
return emptyResult;
|
||||
}
|
||||
if (text === '=') {
|
||||
|
||||
const query = value.endText.getText();
|
||||
const isValue = query[query.indexOf(text) - 1] === '=';
|
||||
if (isValue || text === '=') {
|
||||
return this.getTagValueCompletionItems(value);
|
||||
}
|
||||
return this.getTagsCompletionItems();
|
||||
@ -58,19 +61,17 @@ export default class TempoLanguageProvider extends LanguageProvider {
|
||||
};
|
||||
|
||||
async getTagValueCompletionItems(value: Value) {
|
||||
const tagNames = value.endText.getText().split(' ');
|
||||
let tagName = tagNames[0];
|
||||
// Get last item if multiple tags
|
||||
if (tagNames.length > 1) {
|
||||
tagName = tagNames[tagNames.length - 1];
|
||||
}
|
||||
tagName = tagName.slice(0, -1);
|
||||
const tags = value.endText.getText().split(' ');
|
||||
|
||||
let tagName = tags[tags.length - 1] ?? '';
|
||||
tagName = tagName.split('=')[0];
|
||||
|
||||
const response = await this.request(`/api/search/tag/${tagName}/values`, []);
|
||||
const suggestions: CompletionItemGroup[] = [];
|
||||
|
||||
if (response && response.tagValues) {
|
||||
suggestions.push({
|
||||
label: `TagValues`,
|
||||
label: `Tag Values`,
|
||||
items: response.tagValues.map((tagValue: string) => ({ label: tagValue })),
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user