mirror of
https://github.com/grafana/grafana.git
synced 2024-11-27 19:30:36 -06:00
Loki: Fix labels in LabelBrowser being wrongly cached (#64482)
* remove label cache from label browser * fix spelling Co-authored-by: Gareth Dawson <gareth.dawson@grafana.com> --------- Co-authored-by: Gareth Dawson <gareth.dawson@grafana.com>
This commit is contained in:
parent
68b588b912
commit
976568a337
@ -274,6 +274,40 @@ describe('Request URL', () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe('fetchLabels', () => {
|
||||
it('should return labels', async () => {
|
||||
const datasourceWithLabels = setup({ other: [] });
|
||||
|
||||
const instance = new LanguageProvider(datasourceWithLabels);
|
||||
const labels = await instance.fetchLabels();
|
||||
expect(labels).toEqual(['other']);
|
||||
});
|
||||
|
||||
it('should set labels', async () => {
|
||||
const datasourceWithLabels = setup({ other: [] });
|
||||
|
||||
const instance = new LanguageProvider(datasourceWithLabels);
|
||||
await instance.fetchLabels();
|
||||
expect(instance.labelKeys).toEqual(['other']);
|
||||
});
|
||||
|
||||
it('should return empty array', async () => {
|
||||
const datasourceWithLabels = setup({});
|
||||
|
||||
const instance = new LanguageProvider(datasourceWithLabels);
|
||||
const labels = await instance.fetchLabels();
|
||||
expect(labels).toEqual([]);
|
||||
});
|
||||
|
||||
it('should set empty array', async () => {
|
||||
const datasourceWithLabels = setup({});
|
||||
|
||||
const instance = new LanguageProvider(datasourceWithLabels);
|
||||
await instance.fetchLabels();
|
||||
expect(instance.labelKeys).toEqual([]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('Query imports', () => {
|
||||
const datasource = setup({});
|
||||
|
||||
|
@ -380,6 +380,7 @@ export default class LokiLanguageProvider extends LanguageProvider {
|
||||
.sort()
|
||||
.filter((label) => label !== '__name__');
|
||||
this.labelKeys = labels;
|
||||
return this.labelKeys;
|
||||
}
|
||||
|
||||
return [];
|
||||
|
@ -33,9 +33,9 @@ export const LabelBrowserModal = (props: Props) => {
|
||||
return;
|
||||
}
|
||||
|
||||
datasource.languageProvider.start().then(() => {
|
||||
datasource.languageProvider.fetchLabels().then((labels) => {
|
||||
setLabelsLoaded(true);
|
||||
setHasLogLabels(datasource.languageProvider.getLabelKeys().length > 0);
|
||||
setHasLogLabels(labels.length > 0);
|
||||
});
|
||||
}, [datasource, isOpen]);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user