Skip to content

Commit c24b17f

Browse files
authored
[Discover] Inline noWhiteSpace function (#74331)
* Inline noWhiteSpace function * Fix TypeScript * Remove unused function file
1 parent f97641c commit c24b17f

File tree

2 files changed

+14
-44
lines changed

2 files changed

+14
-44
lines changed

src/legacy/core_plugins/kibana/common/utils/no_white_space.js

Lines changed: 0 additions & 37 deletions
This file was deleted.

src/plugins/discover/public/application/angular/doc_table/components/table_row.ts

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,10 @@
1717
* under the License.
1818
*/
1919

20-
import _ from 'lodash';
20+
import { find, template } from 'lodash';
2121
import $ from 'jquery';
22-
// @ts-ignore
2322
import rison from 'rison-node';
2423
import '../../doc_viewer';
25-
// @ts-ignore
26-
import { noWhiteSpace } from '../../../../../../../legacy/core_plugins/kibana/common/utils/no_white_space';
2724

2825
import openRowHtml from './table_row/open.html';
2926
import detailsHtml from './table_row/details.html';
@@ -35,6 +32,16 @@ import truncateByHeightTemplateHtml from '../components/table_row/truncate_by_he
3532
import { esFilters } from '../../../../../../data/public';
3633
import { getServices } from '../../../../kibana_services';
3734

35+
const TAGS_WITH_WS = />\s+</g;
36+
37+
/**
38+
* Remove all of the whitespace between html tags
39+
* so that inline elements don't have extra spaces.
40+
*/
41+
export function noWhiteSpace(html: string): string {
42+
return html.replace(TAGS_WITH_WS, '><');
43+
}
44+
3845
// guesstimate at the minimum number of chars wide cells in the table should be
3946
const MIN_LINE_LENGTH = 20;
4047

@@ -43,8 +50,8 @@ interface LazyScope extends ng.IScope {
4350
}
4451

4552
export function createTableRowDirective($compile: ng.ICompileService, $httpParamSerializer: any) {
46-
const cellTemplate = _.template(noWhiteSpace(cellTemplateHtml));
47-
const truncateByHeightTemplate = _.template(noWhiteSpace(truncateByHeightTemplateHtml));
53+
const cellTemplate = template(noWhiteSpace(cellTemplateHtml));
54+
const truncateByHeightTemplate = template(noWhiteSpace(truncateByHeightTemplateHtml));
4855

4956
return {
5057
restrict: 'A',
@@ -169,7 +176,7 @@ export function createTableRowDirective($compile: ng.ICompileService, $httpParam
169176
const $cell = $cells.eq(i);
170177
if ($cell.data('discover:html') === html) return;
171178

172-
const reuse = _.find($cells.slice(i + 1), function (cell: any) {
179+
const reuse = find($cells.slice(i + 1), function (cell: any) {
173180
return $.data(cell, 'discover:html') === html;
174181
});
175182

0 commit comments

Comments
 (0)