From 448a834ffd36479664097224a80520e9cb419765 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Sat, 29 Jun 2019 07:49:34 +0200 Subject: [PATCH 01/10] Initial Commit --- .../field_chooser/discover_field.html | 1 - src/legacy/ui/public/directives/field_name.js | 4 +- .../ui/public/directives/field_name_react.tsx | 70 +++++++++++++++++++ 3 files changed, 73 insertions(+), 2 deletions(-) create mode 100644 src/legacy/ui/public/directives/field_name_react.tsx diff --git a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html index 206239f6ae3c4a..cecfa4cc8b2d27 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html +++ b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html @@ -9,7 +9,6 @@ class="sidebar-item-title dscSidebarItem" > diff --git a/src/legacy/ui/public/directives/field_name.js b/src/legacy/ui/public/directives/field_name.js index 6ca0c329b09e7e..40073c1dad4b6e 100644 --- a/src/legacy/ui/public/directives/field_name.js +++ b/src/legacy/ui/public/directives/field_name.js @@ -31,6 +31,7 @@ import numberFieldNameIcon from './field_name_icons/number_field_name_icon.html' import sourceFieldNameIcon from './field_name_icons/source_field_name_icon.html'; import stringFieldNameIcon from './field_name_icons/string_field_name_icon.html'; import unknownFieldNameIcon from './field_name_icons/unknown_field_name_icon.html'; +import { FieldName } from './field_name_react'; import { uiModules } from '../modules'; const module = uiModules.get('kibana'); @@ -46,7 +47,8 @@ const compiledSourceFieldNameIcon = template(sourceFieldNameIcon); const compiledStringFieldNameIcon = template(stringFieldNameIcon); const compiledUnknownFieldNameIcon = template(unknownFieldNameIcon); -module.directive('fieldName', function ($rootScope, config) { +module.directive('fieldName', function ($rootScope, config, reactDirective) { + return reactDirective(FieldName); return { restrict: 'AE', scope: { diff --git a/src/legacy/ui/public/directives/field_name_react.tsx b/src/legacy/ui/public/directives/field_name_react.tsx new file mode 100644 index 00000000000000..8b5a583ae89efe --- /dev/null +++ b/src/legacy/ui/public/directives/field_name_react.tsx @@ -0,0 +1,70 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +// @ts-ignore +import React from 'react'; +import { i18n } from '@kbn/i18n'; + +interface Props { + name: string; + displayName: string; + scripted: boolean; + results: any; + type: string; + field: any; +} + +export function TypeIcon(props: { fieldType: string }) { + switch (props.fieldType) { + case 'string': + return ( + + + + ); + default: + return {props.fieldType}; + } +} + +export function FieldName(props: Props) { + /** $el + .attr('title', name) + .toggleClass('dscField--noResults', results) + .toggleClass('scripted', scripted) + .prepend(typeIcon(type)) + .append($('') + .text(displayName) + .addClass('dscFieldName') + ); + */ + const type = props.field ? props.field.type : props.type; + const name = props.field ? props.field.name : props.displayName; + + return ( + + + {name} + + ); +} From 7480ca794cc015ab6c06962f06a1e4d320f26700 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jul 2019 14:41:41 +0200 Subject: [PATCH 02/10] Add FieldNameIcon for displaying icons by type --- .../directives/field_name/field_name_icon.tsx | 141 ++++++++++++++++++ 1 file changed, 141 insertions(+) create mode 100644 src/legacy/ui/public/directives/field_name/field_name_icon.tsx diff --git a/src/legacy/ui/public/directives/field_name/field_name_icon.tsx b/src/legacy/ui/public/directives/field_name/field_name_icon.tsx new file mode 100644 index 00000000000000..95c25fd96d9294 --- /dev/null +++ b/src/legacy/ui/public/directives/field_name/field_name_icon.tsx @@ -0,0 +1,141 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import { i18n } from '@kbn/i18n'; + +interface Props { + type: string; +} + +export function FieldNameIcon({ type }: Props) { + switch (type) { + case 'boolean': + return ( + + ); + + case 'conflict': + return ( + + ); + + case 'date': + return ( + + ); + + case 'geo_point': + return ( + + ); + + case 'ip': + return ( + + ); + + case 'murmur3': + return ( + + + + ); + + case 'number': + return ( + + + + ); + + case 'source': + return ( + + + + ); + + case 'string': + return ( + + + + ); + + default: + return ( + + + + ); + } +} From 90abee93d3595518957850a388a9d650db38c102 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jul 2019 14:49:21 +0200 Subject: [PATCH 03/10] Add FieldName for displaying icon + name of type --- .../directives/field_name/field_name.tsx | 55 +++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 src/legacy/ui/public/directives/field_name/field_name.tsx diff --git a/src/legacy/ui/public/directives/field_name/field_name.tsx b/src/legacy/ui/public/directives/field_name/field_name.tsx new file mode 100644 index 00000000000000..9054caf0cdc122 --- /dev/null +++ b/src/legacy/ui/public/directives/field_name/field_name.tsx @@ -0,0 +1,55 @@ +/* + * Licensed to Elasticsearch B.V. under one or more contributor + * license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright + * ownership. Elasticsearch B.V. licenses this file to you under + * the Apache License, Version 2.0 (the "License"); you may + * not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ +import React from 'react'; +import classNames from 'classnames'; +import chrome from 'ui/chrome'; +// @ts-ignore +import { shortenDottedString } from '../../../../core_plugins/kibana/common/utils/shorten_dotted_string'; +import { FieldNameIcon } from './field_name_icon'; + +const config = chrome.getUiSettingsClient(); + +interface Props { + field: any; + fieldName: string; + fieldType: string; +} + +export function FieldName(props: Props) { + // field is provided at discover's field chooser + // fieldType and fieldName in kbn_doc_view + // this should be changed when both components are deangularized + const type = props.field ? props.field.type : props.fieldType; + const name = props.field ? props.field.name : props.fieldName; + + const className = classNames({ + 'dscField--noResults': props.field ? !props.field.rowCount && !props.field.scripted : false, + // this is currently not styled + scripted: props.field ? props.field.scripted : false, + }); + const isShortDots = config.get('shortDots:enable'); + const displayName = isShortDots ? shortenDottedString(name) : name; + + return ( + + + {displayName} + + ); +} From 4f9545d187025a40285d7b788dd804dbbac92c01 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jul 2019 14:50:05 +0200 Subject: [PATCH 04/10] Improve and cleanup fieldName directive --- src/legacy/ui/public/directives/field_name.js | 135 ++---------------- 1 file changed, 10 insertions(+), 125 deletions(-) diff --git a/src/legacy/ui/public/directives/field_name.js b/src/legacy/ui/public/directives/field_name.js index 40073c1dad4b6e..1b35e1a2c1fa71 100644 --- a/src/legacy/ui/public/directives/field_name.js +++ b/src/legacy/ui/public/directives/field_name.js @@ -16,133 +16,18 @@ * specific language governing permissions and limitations * under the License. */ - -import $ from 'jquery'; -import { i18n } from '@kbn/i18n'; -import { template } from 'lodash'; -import { shortenDottedString } from '../../../core_plugins/kibana/common/utils/shorten_dotted_string'; -import booleanFieldNameIcon from './field_name_icons/boolean_field_name_icon.html'; -import conflictFieldNameIcon from './field_name_icons/conflict_field_name_icon.html'; -import dateFieldNameIcon from './field_name_icons/date_field_name_icon.html'; -import geoPointFieldNameIcon from './field_name_icons/geo_point_field_name_icon.html'; -import ipFieldNameIcon from './field_name_icons/ip_field_name_icon.html'; -import murmur3FieldNameIcon from './field_name_icons/murmur3_field_name_icon.html'; -import numberFieldNameIcon from './field_name_icons/number_field_name_icon.html'; -import sourceFieldNameIcon from './field_name_icons/source_field_name_icon.html'; -import stringFieldNameIcon from './field_name_icons/string_field_name_icon.html'; -import unknownFieldNameIcon from './field_name_icons/unknown_field_name_icon.html'; -import { FieldName } from './field_name_react'; - +import { FieldName } from './field_name/field_name'; import { uiModules } from '../modules'; const module = uiModules.get('kibana'); -const compiledBooleanFieldNameIcon = template(booleanFieldNameIcon); -const compiledConflictFieldNameIcon = template(conflictFieldNameIcon); -const compiledDateFieldNameIcon = template(dateFieldNameIcon); -const compiledGeoPointFieldNameIcon = template(geoPointFieldNameIcon); -const compiledIpFieldNameIcon = template(ipFieldNameIcon); -const compiledMurmur3FieldNameIcon = template(murmur3FieldNameIcon); -const compiledNumberFieldNameIcon = template(numberFieldNameIcon); -const compiledSourceFieldNameIcon = template(sourceFieldNameIcon); -const compiledStringFieldNameIcon = template(stringFieldNameIcon); -const compiledUnknownFieldNameIcon = template(unknownFieldNameIcon); - module.directive('fieldName', function ($rootScope, config, reactDirective) { - return reactDirective(FieldName); - return { - restrict: 'AE', - scope: { - 'field': '=', - 'fieldName': '=', - 'fieldType': '=' - }, - link: function ($scope, $el) { - const typeToIconMap = { - boolean: compiledBooleanFieldNameIcon({ - booleanFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.booleanAriaLabel', { - defaultMessage: 'Boolean field' - }), - }), - conflict: compiledConflictFieldNameIcon({ - conflictingFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.conflictFieldAriaLabel', { - defaultMessage: 'Conflicting field' - }), - }), - date: compiledDateFieldNameIcon({ - dateFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.dateFieldAriaLabel', { - defaultMessage: 'Date field' - }), - }), - geo_point: compiledGeoPointFieldNameIcon({ - geoPointFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.geoPointFieldAriaLabel', { - defaultMessage: 'Date field' - }), - }), - ip: compiledIpFieldNameIcon({ - ipAddressFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.ipAddressFieldAriaLabel', { - defaultMessage: 'IP address field' - }), - }), - murmur3: compiledMurmur3FieldNameIcon({ - murmur3FieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.murmur3FieldAriaLabel', { - defaultMessage: 'Murmur3 field' - }), - }), - number: compiledNumberFieldNameIcon({ - numberFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.numberFieldAriaLabel', { - defaultMessage: 'Number field' - }), - }), - source: compiledSourceFieldNameIcon({ - sourceFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.sourceFieldAriaLabel', { - defaultMessage: 'Source field' - }), - }), - string: compiledStringFieldNameIcon({ - stringFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.stringFieldAriaLabel', { - defaultMessage: 'String field' - }), - }), - }; - - function typeIcon(fieldType) { - if (typeToIconMap.hasOwnProperty(fieldType)) { - return typeToIconMap[fieldType]; - } - - return compiledUnknownFieldNameIcon({ - unknownFieldAriaLabel: i18n.translate('common.ui.directives.fieldNameIcons.unknownFieldAriaLabel', { - defaultMessage: 'Unknown field' - }), - }); - } - - $rootScope.$watchMulti.call($scope, [ - 'field', - 'fieldName', - 'fieldType', - 'field.rowCount' - ], function () { - - const type = $scope.field ? $scope.field.type : $scope.fieldType; - const name = $scope.field ? $scope.field.name : $scope.fieldName; - const results = $scope.field ? !$scope.field.rowCount && !$scope.field.scripted : false; - const scripted = $scope.field ? $scope.field.scripted : false; - - - const isShortDots = config.get('shortDots:enable'); - const displayName = isShortDots ? shortenDottedString(name) : name; - - $el - .attr('title', name) - .toggleClass('dscField--noResults', results) - .toggleClass('scripted', scripted) - .prepend(typeIcon(type)) - .append($('') - .text(displayName) - .addClass('dscFieldName') - ); - }); - } - }; + return reactDirective( + FieldName, + [ + ['field', { watchDepth: 'collection' }], + ['fieldName', { watchDepth: 'reference' }], + ['fieldType', { watchDepth: 'reference' }], + ], + { restrict: 'AE' } + ); }); From 8d204f0f86dfaca695c1954ecd7dda42aa1ab209 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Wed, 10 Jul 2019 14:50:36 +0200 Subject: [PATCH 05/10] Cleanup unused files --- .../boolean_field_name_icon.html | 4 -- .../conflict_field_name_icon.html | 4 -- .../date_field_name_icon.html | 4 -- .../geo_point_field_name_icon.html | 4 -- .../field_name_icons/ip_field_name_icon.html | 4 -- .../murmur3_field_name_icon.html | 6 -- .../number_field_name_icon.html | 6 -- .../source_field_name_icon.html | 4 -- .../string_field_name_icon.html | 6 -- .../unknown_field_name_icon.html | 6 -- .../ui/public/directives/field_name_react.tsx | 70 ------------------- 11 files changed, 118 deletions(-) delete mode 100644 src/legacy/ui/public/directives/field_name_icons/boolean_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/conflict_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/date_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/geo_point_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/ip_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/murmur3_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/number_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/source_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/string_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_icons/unknown_field_name_icon.html delete mode 100644 src/legacy/ui/public/directives/field_name_react.tsx diff --git a/src/legacy/ui/public/directives/field_name_icons/boolean_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/boolean_field_name_icon.html deleted file mode 100644 index f863acf5b71bb8..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/boolean_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/conflict_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/conflict_field_name_icon.html deleted file mode 100644 index d90dd392044b90..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/conflict_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/date_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/date_field_name_icon.html deleted file mode 100644 index 051f33971214cf..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/date_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/geo_point_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/geo_point_field_name_icon.html deleted file mode 100644 index 730eb780028c52..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/geo_point_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/ip_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/ip_field_name_icon.html deleted file mode 100644 index a5094852515487..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/ip_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/murmur3_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/murmur3_field_name_icon.html deleted file mode 100644 index ea7ca535d36cd4..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/murmur3_field_name_icon.html +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/src/legacy/ui/public/directives/field_name_icons/number_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/number_field_name_icon.html deleted file mode 100644 index 9971555b63f016..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/number_field_name_icon.html +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/src/legacy/ui/public/directives/field_name_icons/source_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/source_field_name_icon.html deleted file mode 100644 index 59c3053ff8cff2..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/source_field_name_icon.html +++ /dev/null @@ -1,4 +0,0 @@ - diff --git a/src/legacy/ui/public/directives/field_name_icons/string_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/string_field_name_icon.html deleted file mode 100644 index d16a9073f61cce..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/string_field_name_icon.html +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/src/legacy/ui/public/directives/field_name_icons/unknown_field_name_icon.html b/src/legacy/ui/public/directives/field_name_icons/unknown_field_name_icon.html deleted file mode 100644 index ee2edee4e94507..00000000000000 --- a/src/legacy/ui/public/directives/field_name_icons/unknown_field_name_icon.html +++ /dev/null @@ -1,6 +0,0 @@ - - - diff --git a/src/legacy/ui/public/directives/field_name_react.tsx b/src/legacy/ui/public/directives/field_name_react.tsx deleted file mode 100644 index 8b5a583ae89efe..00000000000000 --- a/src/legacy/ui/public/directives/field_name_react.tsx +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Licensed to Elasticsearch B.V. under one or more contributor - * license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright - * ownership. Elasticsearch B.V. licenses this file to you under - * the Apache License, Version 2.0 (the "License"); you may - * not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, - * software distributed under the License is distributed on an - * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY - * KIND, either express or implied. See the License for the - * specific language governing permissions and limitations - * under the License. - */ -// @ts-ignore -import React from 'react'; -import { i18n } from '@kbn/i18n'; - -interface Props { - name: string; - displayName: string; - scripted: boolean; - results: any; - type: string; - field: any; -} - -export function TypeIcon(props: { fieldType: string }) { - switch (props.fieldType) { - case 'string': - return ( - - - - ); - default: - return {props.fieldType}; - } -} - -export function FieldName(props: Props) { - /** $el - .attr('title', name) - .toggleClass('dscField--noResults', results) - .toggleClass('scripted', scripted) - .prepend(typeIcon(type)) - .append($('') - .text(displayName) - .addClass('dscFieldName') - ); - */ - const type = props.field ? props.field.type : props.type; - const name = props.field ? props.field.name : props.displayName; - - return ( - - - {name} - - ); -} From 05a6c91994896a6f08a5f0c641a12e78974a4bc2 Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 11 Jul 2019 09:02:53 +0200 Subject: [PATCH 06/10] Fix mocha tests --- .../public/__tests__/doc_views.js | 46 ++++++++++--------- 1 file changed, 24 insertions(+), 22 deletions(-) diff --git a/src/legacy/core_plugins/kbn_doc_views/public/__tests__/doc_views.js b/src/legacy/core_plugins/kbn_doc_views/public/__tests__/doc_views.js index 4bd41bfa3968e3..fb47b9af2af7b0 100644 --- a/src/legacy/core_plugins/kbn_doc_views/public/__tests__/doc_views.js +++ b/src/legacy/core_plugins/kbn_doc_views/public/__tests__/doc_views.js @@ -101,13 +101,15 @@ describe('docViews', function () { it('should have the field name in the first column', function () { _.each(_.keys(flattened), function (field) { - expect($elem.find('td[title="' + field + '"]').length).to.be(1); + expect($elem.find('[data-test-subj="tableDocViewRow-' + field + '"]').length).to.be(1); }); }); it('should have the a value for each field', function () { _.each(_.keys(flattened), function (field) { - const cellValue = $elem.find('td[title="' + field + '"]').siblings().find('.kbnDocViewer__value').text(); + const cellValue = $elem + .find('[data-test-subj="tableDocViewRow-' + field + '"]') + .find('.kbnDocViewer__value').text(); // This sucks, but testing the filter chain is too hairy ATM expect(cellValue.length).to.be.greaterThan(0); @@ -117,48 +119,48 @@ describe('docViews', function () { describe('filtering', function () { it('should apply a filter when clicking filterable fields', function () { - const cell = $elem.find('td[title="bytes"]').prev(); + const row = $elem.find('[data-test-subj="tableDocViewRow-bytes"]'); - cell.find('.fa-search-plus').first().click(); + row.find('.fa-search-plus').first().click(); expect($scope.filter.calledOnce).to.be(true); - cell.find('.fa-search-minus').first().click(); + row.find('.fa-search-minus').first().click(); expect($scope.filter.calledTwice).to.be(true); - cell.find('.fa-asterisk').first().click(); + row.find('.fa-asterisk').first().click(); expect($scope.filter.calledThrice).to.be(true); }); it('should NOT apply a filter when clicking non-filterable fields', function () { - const cell = $elem.find('td[title="area"]').prev(); + const row = $elem.find('[data-test-subj="tableDocViewRow-area"]'); - cell.find('.fa-search-plus').first().click(); + row.find('.fa-search-plus').first().click(); expect($scope.filter.calledOnce).to.be(false); - cell.find('.fa-search-minus').first().click(); + row.find('.fa-search-minus').first().click(); expect($scope.filter.calledTwice).to.be(false); - cell.find('.fa-asterisk').first().click(); + row.find('.fa-asterisk').first().click(); expect($scope.filter.calledOnce).to.be(true); }); }); describe('warnings', function () { it('displays a warning about field name starting with underscore', function () { - const cells = $elem.find('td[title="_underscore"]').siblings(); - expect(cells.find('.kbnDocViewer__underscore').length).to.be(1); - expect(cells.find('.kbnDocViewer__noMapping').length).to.be(0); - expect(cells.find('.kbnDocViewer__objectArray').length).to.be(0); + const row = $elem.find('[data-test-subj="tableDocViewRow-_underscore"]'); + expect(row.find('.kbnDocViewer__underscore').length).to.be(1); + expect(row.find('.kbnDocViewer__noMapping').length).to.be(0); + expect(row.find('.kbnDocViewer__objectArray').length).to.be(0); }); it('displays a warning about missing mappings', function () { - const cells = $elem.find('td[title="noMapping"]').siblings(); - expect(cells.find('.kbnDocViewer__underscore').length).to.be(0); - expect(cells.find('.kbnDocViewer__noMapping').length).to.be(1); - expect(cells.find('.kbnDocViewer__objectArray').length).to.be(0); + const row = $elem.find('[data-test-subj="tableDocViewRow-noMapping"]'); + expect(row.find('.kbnDocViewer__underscore').length).to.be(0); + expect(row.find('.kbnDocViewer__noMapping').length).to.be(1); + expect(row.find('.kbnDocViewer__objectArray').length).to.be(0); }); it('displays a warning about objects in arrays', function () { - const cells = $elem.find('td[title="objectArray"]').siblings(); - expect(cells.find('.kbnDocViewer__underscore').length).to.be(0); - expect(cells.find('.kbnDocViewer__noMapping').length).to.be(0); - expect(cells.find('.kbnDocViewer__objectArray').length).to.be(1); + const row = $elem.find('[data-test-subj="tableDocViewRow-objectArray"]'); + expect(row.find('.kbnDocViewer__underscore').length).to.be(0); + expect(row.find('.kbnDocViewer__noMapping').length).to.be(0); + expect(row.find('.kbnDocViewer__objectArray').length).to.be(1); }); }); From b0c9e118dc0f22e9705c8b2147e27f29b74fcd8d Mon Sep 17 00:00:00 2001 From: Matthias Wilhelm Date: Thu, 11 Jul 2019 16:25:35 +0200 Subject: [PATCH 07/10] Finetuning --- .../discover/components/field_chooser/discover_field.html | 8 +++++--- src/legacy/ui/public/directives/field_name/field_name.tsx | 8 ++++---- .../ui/public/directives/field_name/field_name_icon.tsx | 4 +--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html index cecfa4cc8b2d27..06e7cc50754118 100644 --- a/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html +++ b/src/legacy/core_plugins/kibana/public/discover/components/field_chooser/discover_field.html @@ -8,9 +8,11 @@ kbn-accessible-click class="sidebar-item-title dscSidebarItem" > - +
+ +