Loki: Remove showing of unique labels with the empty string value (#30363)

* Remove empty unique label values

* Add test

* Simplify
This commit is contained in:
Ivana Huckova 2021-01-19 11:06:51 +01:00 committed by GitHub
parent 202f88c610
commit 086c77f5e3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -20,4 +20,9 @@ describe('<LogLabels />', () => {
expect(wrapper.text()).not.toContain('42');
expect(wrapper.text()).not.toContain('13');
});
it('excludes labels with empty string values', () => {
const wrapper = shallow(<LogLabels labels={{ foo: 'bar', baz: '' }} theme={getTheme()} />);
expect(wrapper.text()).toContain('bar');
expect(wrapper.html()).not.toContain('baz');
});
});

View File

@ -59,6 +59,9 @@ export const UnThemedLogLabels: FunctionComponent<Props> = ({ labels, theme }) =
<span className={cx([styles.logsLabels])}>
{displayLabels.sort().map(label => {
const value = labels[label];
if (!value) {
return;
}
const tooltip = `${label}: ${value}`;
return (
<span key={label} className={cx([styles.logsLabel])}>