Skip to content

Commit

Permalink
[TSVB] Use the empty label for / terms (#154647)
Browse files Browse the repository at this point in the history
## Summary

Closes #150993

In case there is a single `/` in the markdown it uses the (empty) label
as we are doing in other cases.

<img width="808" alt="image"
src="https://user-images.githubusercontent.com/17003240/230896158-fbdb2f73-76c3-44a0-8e69-041dadd379a6.png">


### Checklist

- [ ] [Unit or functional
tests](https://www.elastic.co/guide/en/kibana/master/development-tests.html)
were updated or added to match the most common scenarios
  • Loading branch information
stratoula authored Apr 11, 2023
1 parent 7db297b commit d9d535e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/plugins/vis_types/timeseries/common/empty_label.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

import { getValueOrEmpty } from './empty_label';

describe('getValueOrEmpty', () => {
test('returns the value if not empty or slash value given', () => {
expect(getValueOrEmpty('/test/blog')).toEqual('/test/blog');
});

test('returns (empty) if value is slash', () => {
expect(getValueOrEmpty('/')).toEqual('(empty)');
});

test('returns (empty) if value is empty', () => {
expect(getValueOrEmpty('')).toEqual('(empty)');
});

test('returns (empty) if value is null', () => {
expect(getValueOrEmpty(null)).toEqual('(empty)');
});
});
2 changes: 1 addition & 1 deletion src/plugins/vis_types/timeseries/common/empty_label.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const emptyLabel = i18n.translate('visTypeTimeseries.emptyTextValue', {
});

export const getValueOrEmpty = (value: unknown) => {
if (value === '' || value === null || value === undefined) {
if (value === '' || value === '/' || value === null || value === undefined) {
return emptyLabel;
}
return `${value}`;
Expand Down

0 comments on commit d9d535e

Please sign in to comment.