Tempo: Only add option to values dropdown if there is a value (#72524)

Only add option to list if there is a values
This commit is contained in:
Joey 2023-08-18 08:17:56 +01:00 committed by GitHub
parent f169151143
commit ab94c9d730
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -121,11 +121,15 @@ export default class TempoLanguageProvider extends LanguageProvider {
const response = await this.request(`/api/v2/search/tag/${tag}/values`, query ? { q: query } : {});
let options: Array<SelectableValue<string>> = [];
if (response && response.tagValues) {
options = response.tagValues.map((v: { type: string; value: string }) => ({
type: v.type,
value: v.value,
label: v.value,
}));
response.tagValues.forEach((v: { type: string; value?: string }) => {
if (v.value) {
options.push({
type: v.type,
value: v.value,
label: v.value,
});
}
});
}
return options;
}