* Allow re-editing of labels in Loki queries
* Update public/app/plugins/datasource/loki/language_provider.ts
(cherry picked from commit 240e65f693)
Co-authored-by: Ivana Huckova <30407135+ivanahuckova@users.noreply.github.com>
This commit is contained in:
co-authored by
Ivana Huckova
parent
0e9b553daf
commit
46daba67d2
@@ -167,6 +167,25 @@ describe('Language completion provider', () => {
|
||||
},
|
||||
]);
|
||||
});
|
||||
it('returns label values suggestions from Loki when re-editing', async () => {
|
||||
const datasource = makeMockLokiDatasource({ label1: ['label1_val1', 'label1_val2'], label2: [] });
|
||||
const provider = await getLanguageProvider(datasource);
|
||||
const input = createTypeaheadInput('{label1="label1_v"}', 'label1_v', 'label1', 17, [
|
||||
'attr-value',
|
||||
'context-labels',
|
||||
]);
|
||||
let result = await provider.provideCompletionItems(input);
|
||||
expect(result.context).toBe('context-label-values');
|
||||
expect(result.suggestions).toEqual([
|
||||
{
|
||||
items: [
|
||||
{ label: 'label1_val1', filterText: '"label1_val1"' },
|
||||
{ label: 'label1_val2', filterText: '"label1_val2"' },
|
||||
],
|
||||
label: 'Label values for "label1"',
|
||||
},
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('label values', () => {
|
||||
|
||||
@@ -268,7 +268,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
|
||||
selector = EMPTY_SELECTOR;
|
||||
}
|
||||
|
||||
if (!isValueStart && selector === EMPTY_SELECTOR) {
|
||||
if (!labelKey && selector === EMPTY_SELECTOR) {
|
||||
// start task gets all labels
|
||||
await this.start();
|
||||
const allLabels = this.getLabelKeys();
|
||||
|
||||
Reference in New Issue
Block a user