Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Discover] Inline noWhiteSpace function #74331

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 0 additions & 37 deletions src/legacy/core_plugins/kibana/common/utils/no_white_space.js

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@
* under the License.
*/

import _ from 'lodash';
import { find, template } from 'lodash';
import $ from 'jquery';
// @ts-ignore
import rison from 'rison-node';
import '../../doc_viewer';
// @ts-ignore
import { noWhiteSpace } from '../../../../../../../legacy/core_plugins/kibana/common/utils/no_white_space';

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

const TAGS_WITH_WS = />\s+</g;

/**
* Remove all of the whitespace between html tags
* so that inline elements don't have extra spaces.
*/
export function noWhiteSpace(html: string): string {
return html.replace(TAGS_WITH_WS, '><');
}

// guesstimate at the minimum number of chars wide cells in the table should be
const MIN_LINE_LENGTH = 20;

Expand All @@ -43,8 +50,8 @@ interface LazyScope extends ng.IScope {
}

export function createTableRowDirective($compile: ng.ICompileService, $httpParamSerializer: any) {
const cellTemplate = _.template(noWhiteSpace(cellTemplateHtml));
const truncateByHeightTemplate = _.template(noWhiteSpace(truncateByHeightTemplateHtml));
const cellTemplate = template(noWhiteSpace(cellTemplateHtml));
const truncateByHeightTemplate = template(noWhiteSpace(truncateByHeightTemplateHtml));

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

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

Expand Down