From 0d4e58398add5bb92d0a7c23f2382ca240e5c4ac Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Thu, 4 Apr 2019 17:06:25 +0300 Subject: [PATCH 01/12] Delete label filter --- src/legacy/ui/public/agg_types/agg_params.js | 1 - .../public/directives/saved_object_finder.js | 5 +- .../ui/public/filters/__tests__/label.js | 54 ------------------- src/legacy/ui/public/filters/label.js | 29 ---------- .../public/partials/saved_object_finder.html | 2 +- 5 files changed, 5 insertions(+), 86 deletions(-) delete mode 100644 src/legacy/ui/public/filters/__tests__/label.js delete mode 100644 src/legacy/ui/public/filters/label.js diff --git a/src/legacy/ui/public/agg_types/agg_params.js b/src/legacy/ui/public/agg_types/agg_params.js index 7a4e360484b90..13c7cc0db57e8 100644 --- a/src/legacy/ui/public/agg_types/agg_params.js +++ b/src/legacy/ui/public/agg_types/agg_params.js @@ -17,7 +17,6 @@ * under the License. */ -import '../filters/label'; import { IndexedArray } from '../indexed_array'; import { FieldParamType } from './param_types/field'; import { OptionedParamType } from './param_types/optioned'; diff --git a/src/legacy/ui/public/directives/saved_object_finder.js b/src/legacy/ui/public/directives/saved_object_finder.js index b97e366ca0bd8..ef443939511a6 100644 --- a/src/legacy/ui/public/directives/saved_object_finder.js +++ b/src/legacy/ui/public/directives/saved_object_finder.js @@ -22,7 +22,6 @@ import rison from 'rison-node'; import { keyMap } from '../utils/key_map'; import { SavedObjectRegistryProvider } from '../saved_objects/saved_object_registry'; import { uiModules } from '../modules'; -import '../filters/label'; import savedObjectFinderTemplate from '../partials/saved_object_finder.html'; import './input_focus'; import './paginate'; @@ -158,6 +157,10 @@ module.directive('savedObjectFinder', function ($location, kbnUrl, Private, conf index: -1 }; + self.getLabel = function () { + return _.words(self.properties.nouns).map(_.capitalize).join(' '); + }; + //key handler for the filter text box self.filterKeyDown = function ($event) { switch (keyMap[$event.keyCode]) { diff --git a/src/legacy/ui/public/filters/__tests__/label.js b/src/legacy/ui/public/filters/__tests__/label.js deleted file mode 100644 index 1696415229749..0000000000000 --- a/src/legacy/ui/public/filters/__tests__/label.js +++ /dev/null @@ -1,54 +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. - */ - -import expect from '@kbn/expect'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/discover/index'; - -// Load kibana and its applications - -let filter; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($filter) { - filter = $filter('label'); - }); -}; - -describe('label filter', function () { - beforeEach(function () { - init(); - }); - - it('should have a label filter', function () { - expect(filter).to.not.be(null); - }); - - it('should capitalize the first letter in a string', function () { - expect(filter('something')).to.be('Something'); - }); - - it('should capitalize the first letter in every word', function () { - expect(filter('foo bar fizz buzz')).to.be('Foo Bar Fizz Buzz'); - }); -}); diff --git a/src/legacy/ui/public/filters/label.js b/src/legacy/ui/public/filters/label.js deleted file mode 100644 index 34824448c793d..0000000000000 --- a/src/legacy/ui/public/filters/label.js +++ /dev/null @@ -1,29 +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. - */ - -import { uiModules } from '../modules'; -import { words, capitalize } from 'lodash'; - -uiModules - .get('kibana') - .filter('label', function () { - return function (str) { - return words(str).map(capitalize).join(' '); - }; - }); diff --git a/src/legacy/ui/public/partials/saved_object_finder.html b/src/legacy/ui/public/partials/saved_object_finder.html index 3ce944c41f7ad..adf7f5dacae9a 100644 --- a/src/legacy/ui/public/partials/saved_object_finder.html +++ b/src/legacy/ui/public/partials/saved_object_finder.html @@ -11,7 +11,7 @@ input-focus disable-input-focus="disableAutoFocus" ng-model="filter" - ng-attr-placeholder="{{ finder.properties.nouns | label }} Filter..." + ng-attr-placeholder="{{ finder.getLabel() }} Filter..." ng-keydown="finder.filterKeyDown($event)" name="filter" type="text" From a6ad60a25ebca4ba37fa74bd21dfc6db83c9045b Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Thu, 4 Apr 2019 17:18:06 +0300 Subject: [PATCH 02/12] Delete risonDecode --- src/legacy/ui/public/filters/__tests__/rison.js | 12 ------------ src/legacy/ui/public/filters/rison.js | 6 ------ 2 files changed, 18 deletions(-) diff --git a/src/legacy/ui/public/filters/__tests__/rison.js b/src/legacy/ui/public/filters/__tests__/rison.js index 62accfa8118a7..3a4e02334125e 100644 --- a/src/legacy/ui/public/filters/__tests__/rison.js +++ b/src/legacy/ui/public/filters/__tests__/rison.js @@ -24,7 +24,6 @@ import 'plugins/kibana/discover/index'; // Load kibana and its applications let rison; -let risonDecode; const init = function () { // Load the application @@ -33,7 +32,6 @@ const init = function () { // Create the scope ngMock.inject(function ($filter) { rison = $filter('rison'); - risonDecode = $filter('risonDecode'); }); }; @@ -59,14 +57,4 @@ describe('rison filters', function () { expect(rison(testObj)).to.be(testRison); }); }); - - describe('risonDecode', function () { - it('should have the filter', function () { - expect(risonDecode).to.not.be(null); - }); - - it('should decode rison data', function () { - expect(risonDecode(testRison)).to.eql(testObj); - }); - }); }); diff --git a/src/legacy/ui/public/filters/rison.js b/src/legacy/ui/public/filters/rison.js index 32a794963b455..be92c050e11ea 100644 --- a/src/legacy/ui/public/filters/rison.js +++ b/src/legacy/ui/public/filters/rison.js @@ -26,9 +26,3 @@ module.filter('rison', function () { return rison.encode(str); }; }); - -module.filter('risonDecode', function () { - return function (str) { - return rison.decode(str); - }; -}); From dc6b93d23a7fef51baf890549a56b1e74ba5a83b Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Thu, 4 Apr 2019 17:19:16 +0300 Subject: [PATCH 03/12] Deleted rison --- .../ui/public/filters/__tests__/rison.js | 60 ------------------- src/legacy/ui/public/filters/rison.js | 28 --------- 2 files changed, 88 deletions(-) delete mode 100644 src/legacy/ui/public/filters/__tests__/rison.js delete mode 100644 src/legacy/ui/public/filters/rison.js diff --git a/src/legacy/ui/public/filters/__tests__/rison.js b/src/legacy/ui/public/filters/__tests__/rison.js deleted file mode 100644 index 3a4e02334125e..0000000000000 --- a/src/legacy/ui/public/filters/__tests__/rison.js +++ /dev/null @@ -1,60 +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. - */ - -import expect from '@kbn/expect'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/discover/index'; - -// Load kibana and its applications - -let rison; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($filter) { - rison = $filter('rison'); - }); -}; - -describe('rison filters', function () { - const testObj = { - time: { - from: 'now-15m', - to: 'now' - } - }; - const testRison = '(time:(from:now-15m,to:now))'; - - beforeEach(function () { - init(); - }); - - describe('rison', function () { - it('should have the filter', function () { - expect(rison).to.not.be(null); - }); - - it('should rison encode data', function () { - expect(rison(testObj)).to.be(testRison); - }); - }); -}); diff --git a/src/legacy/ui/public/filters/rison.js b/src/legacy/ui/public/filters/rison.js deleted file mode 100644 index be92c050e11ea..0000000000000 --- a/src/legacy/ui/public/filters/rison.js +++ /dev/null @@ -1,28 +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. - */ - -import rison from 'rison-node'; -import { uiModules } from '../modules'; -const module = uiModules.get('kibana'); - -module.filter('rison', function () { - return function (str) { - return rison.encode(str); - }; -}); From 6e827d8f1de19ffc770a55fa7c95eaea18ef7cc9 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Thu, 4 Apr 2019 18:11:21 +0300 Subject: [PATCH 04/12] Removed rison --- src/legacy/ui/public/url/__tests__/url.js | 2 +- src/legacy/ui/public/url/url.js | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/legacy/ui/public/url/__tests__/url.js b/src/legacy/ui/public/url/__tests__/url.js index 52af742492aed..651ad3c9c1691 100644 --- a/src/legacy/ui/public/url/__tests__/url.js +++ b/src/legacy/ui/public/url/__tests__/url.js @@ -210,7 +210,7 @@ describe('kbnUrl', function () { const wrappers = [ ['{{', '}}'], ['{{ ', ' }}'], ['{{', ' }}'], ['{{ ', '}}'], ['{{ ', ' }}']]; // make sure filters are evaluated via angular expressions const objIndex = 4; // used to case one replace as an object - const filters = ['', 'uppercase', '', 'uppercase', 'rison']; + const filters = ['', 'uppercase', '', 'uppercase']; // the words (template keys) used must all be unique const words = _.uniq(faker.Lorem.words(10)).slice(0, urlParts.length).map(function (word, i) { diff --git a/src/legacy/ui/public/url/url.js b/src/legacy/ui/public/url/url.js index dbb454b80dbc6..eee3c6cc02056 100644 --- a/src/legacy/ui/public/url/url.js +++ b/src/legacy/ui/public/url/url.js @@ -19,7 +19,6 @@ import _ from 'lodash'; import '../filters/uriescape'; -import '../filters/rison'; import { uiModules } from '../modules'; import { AppStateProvider } from '../state_management/app_state'; From 9f7c8259088bfd6215ecace2a2a81c7a367141da Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Thu, 4 Apr 2019 18:12:28 +0300 Subject: [PATCH 05/12] removed fieldType filter --- .../agg_types/buckets/date_histogram.js | 1 - .../ui/public/agg_types/param_types/field.js | 1 - src/legacy/ui/public/filters/field_type.js | 30 ------------------- 3 files changed, 32 deletions(-) delete mode 100644 src/legacy/ui/public/filters/field_type.js diff --git a/src/legacy/ui/public/agg_types/buckets/date_histogram.js b/src/legacy/ui/public/agg_types/buckets/date_histogram.js index acfd9548556a7..923169f2b4da0 100644 --- a/src/legacy/ui/public/agg_types/buckets/date_histogram.js +++ b/src/legacy/ui/public/agg_types/buckets/date_histogram.js @@ -20,7 +20,6 @@ import _ from 'lodash'; import chrome from '../../chrome'; import moment from 'moment-timezone'; -import '../../filters/field_type'; import '../directives/validate_date_interval'; import { BucketAggType } from './_bucket_agg_type'; import { TimeBuckets } from '../../time_buckets'; diff --git a/src/legacy/ui/public/agg_types/param_types/field.js b/src/legacy/ui/public/agg_types/param_types/field.js index 7a02d2ac6ef21..800b0e4a4f03f 100644 --- a/src/legacy/ui/public/agg_types/param_types/field.js +++ b/src/legacy/ui/public/agg_types/param_types/field.js @@ -24,7 +24,6 @@ import '../filter/comma_list'; import editorHtml from '../controls/field.html'; import { BaseParamType } from './base'; import '../filters/sort_prefix_first'; -import '../../filters/field_type'; import { IndexedArray } from '../../indexed_array'; import { toastNotifications } from '../../notify'; import { createLegacyClass } from '../../utils/legacy_class'; diff --git a/src/legacy/ui/public/filters/field_type.js b/src/legacy/ui/public/filters/field_type.js deleted file mode 100644 index eab29762b5508..0000000000000 --- a/src/legacy/ui/public/filters/field_type.js +++ /dev/null @@ -1,30 +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. - */ - -import { propFilter } from './_prop_filter'; -import { uiModules } from '../modules'; -// Gets all fields of a given type. -// You may also pass "*" to get all types -// Or an array of types to get all fields of that type - -uiModules - .get('kibana') - .filter('fieldType', function () { - return propFilter('type'); - }); From 8151eb6ee0b738d4e0c80370e1403e8aedde50c0 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 7 Apr 2019 12:23:33 +0300 Subject: [PATCH 06/12] Deleted field type tests --- .../ui/public/filters/__tests__/field_type.js | 83 ------------------- 1 file changed, 83 deletions(-) delete mode 100644 src/legacy/ui/public/filters/__tests__/field_type.js diff --git a/src/legacy/ui/public/filters/__tests__/field_type.js b/src/legacy/ui/public/filters/__tests__/field_type.js deleted file mode 100644 index 0b969095eb499..0000000000000 --- a/src/legacy/ui/public/filters/__tests__/field_type.js +++ /dev/null @@ -1,83 +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. - */ - -import expect from '@kbn/expect'; -import _ from 'lodash'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/discover/index'; -import '../field_type'; - -let filter; - -let types; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - types = [ - { name: 's1', type: 'string' }, - { name: 's2', type: 'string' }, - { name: 's3', type: 'string' }, - - { name: 'n1', type: 'number' }, - { name: 'n2', type: 'number' }, - - { name: 'i1', type: 'ip' }, - { name: 'd1', type: 'date' }, - ]; - - // Create the scope - ngMock.inject(function ($filter) { - filter = $filter('fieldType'); - }); -}; - - -describe('fieldType array filter', function () { - - beforeEach(function () { - init(); - }); - - it('should have a fieldType filter', function () { - expect(filter).to.not.be(null); - }); - - it('should have 3 string fields', function () { - expect(filter(types, 'string').length).to.be(3); - }); - - it('should have 2 number fields', function () { - expect(filter(types, 'number').length).to.be(2); - }); - - it('should have 1 ip field and 1 date field', function () { - expect(_.pluck(filter(types, ['date', 'ip']), 'name')).to.eql(['i1', 'd1']); - }); - - it('should return all fields when passed *', function () { - expect(filter(types, '*').length).to.be(7); - }); - - it('should allow negation', function () { - const resultNames = _.pluck(filter(types, '!string'), 'name'); - expect(resultNames).to.eql(['n1', 'n2', 'i1', 'd1']); - }); -}); From 567ebda7b2ac6b5762aade3146b11ce841107939 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 7 Apr 2019 12:43:28 +0300 Subject: [PATCH 07/12] Replaced uriescape filter with use of encodeURIComponent --- .../public/doc_table/components/table_row.js | 2 +- .../components/table_row/details.html | 2 +- .../ui/public/filters/__tests__/uriescape.js | 52 ------------------- src/legacy/ui/public/filters/uriescape.js | 27 ---------- src/legacy/ui/public/url/url.js | 8 +-- 5 files changed, 3 insertions(+), 88 deletions(-) delete mode 100644 src/legacy/ui/public/filters/__tests__/uriescape.js delete mode 100644 src/legacy/ui/public/filters/uriescape.js diff --git a/src/legacy/ui/public/doc_table/components/table_row.js b/src/legacy/ui/public/doc_table/components/table_row.js index c3e3ba9b80c83..1f86d1a19edf0 100644 --- a/src/legacy/ui/public/doc_table/components/table_row.js +++ b/src/legacy/ui/public/doc_table/components/table_row.js @@ -21,7 +21,6 @@ import _ from 'lodash'; import $ from 'jquery'; import rison from 'rison-node'; import '../../doc_viewer'; -import '../../filters/uriescape'; import '../../filters/short_dots'; import { noWhiteSpace } from '../../../../core_plugins/kibana/common/utils/no_white_space'; import openRowHtml from './table_row/open.html'; @@ -95,6 +94,7 @@ module.directive('kbnTableRow', function ($compile, $httpParamSerializer, kbnUrl $detailsTr.html(detailsHtml); $detailsScope.row = $scope.row; + $detailsScope.uriEncodedId = encodeURIComponent($detailsScope.row._id); $compile($detailsTr)($detailsScope); }; diff --git a/src/legacy/ui/public/doc_table/components/table_row/details.html b/src/legacy/ui/public/doc_table/components/table_row/details.html index fa1fbee5d8f55..d90f4bbc25e25 100644 --- a/src/legacy/ui/public/doc_table/components/table_row/details.html +++ b/src/legacy/ui/public/doc_table/components/table_row/details.html @@ -30,7 +30,7 @@ diff --git a/src/legacy/ui/public/filters/__tests__/uriescape.js b/src/legacy/ui/public/filters/__tests__/uriescape.js deleted file mode 100644 index 49a7034593821..0000000000000 --- a/src/legacy/ui/public/filters/__tests__/uriescape.js +++ /dev/null @@ -1,52 +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. - */ - -import expect from '@kbn/expect'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/discover/index'; - - -let filter; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($filter) { - filter = $filter('uriescape'); - }); -}; - - -describe('uriescape filter', function () { - - beforeEach(function () { - init(); - }); - - it('should have a uriescape filter', function () { - expect(filter).to.not.be(null); - }); - - it('should encodeURIComponent a string', function () { - expect(filter('this and that')).to.be('this%20and%20that'); - }); - -}); diff --git a/src/legacy/ui/public/filters/uriescape.js b/src/legacy/ui/public/filters/uriescape.js deleted file mode 100644 index c4fc4fe178fe1..0000000000000 --- a/src/legacy/ui/public/filters/uriescape.js +++ /dev/null @@ -1,27 +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. - */ - -import { uiModules } from '../modules'; -uiModules - .get('kibana') - .filter('uriescape', function () { - return function (str) { - return encodeURIComponent(str); - }; - }); diff --git a/src/legacy/ui/public/url/url.js b/src/legacy/ui/public/url/url.js index eee3c6cc02056..c2de5a9bd3eaf 100644 --- a/src/legacy/ui/public/url/url.js +++ b/src/legacy/ui/public/url/url.js @@ -18,7 +18,6 @@ */ import _ from 'lodash'; -import '../filters/uriescape'; import { uiModules } from '../modules'; import { AppStateProvider } from '../state_management/app_state'; @@ -120,12 +119,7 @@ export function KbnUrlProvider($injector, $location, $rootScope, $parse, Private })); } - // append uriescape filter if not included - if (expr.indexOf('uriescape') === -1) { - expr += '|uriescape'; - } - - return $parse(expr)(paramObj); + return encodeURIComponent($parse(expr)(paramObj)); }); }; From 26925a8be58cf5a736412519298852d43fb07eed Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 7 Apr 2019 13:49:29 +0300 Subject: [PATCH 08/12] Fixed url test --- src/legacy/ui/public/url/__tests__/url.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/legacy/ui/public/url/__tests__/url.js b/src/legacy/ui/public/url/__tests__/url.js index 651ad3c9c1691..122c17428f945 100644 --- a/src/legacy/ui/public/url/__tests__/url.js +++ b/src/legacy/ui/public/url/__tests__/url.js @@ -210,7 +210,7 @@ describe('kbnUrl', function () { const wrappers = [ ['{{', '}}'], ['{{ ', ' }}'], ['{{', ' }}'], ['{{ ', '}}'], ['{{ ', ' }}']]; // make sure filters are evaluated via angular expressions const objIndex = 4; // used to case one replace as an object - const filters = ['', 'uppercase', '', 'uppercase']; + const filters = ['', 'uppercase', '', 'uppercase', '']; // the words (template keys) used must all be unique const words = _.uniq(faker.Lorem.words(10)).slice(0, urlParts.length).map(function (word, i) { From fbd6d530d1e1c6e8ed43d476a290a98629856740 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 7 Apr 2019 14:16:05 +0300 Subject: [PATCH 09/12] Delete short dots filter --- src/legacy/ui/public/directives/field_name.js | 6 +- .../ui/public/filters/__tests__/short_dots.js | 70 ------------------- src/legacy/ui/public/filters/short_dots.js | 46 ------------ 3 files changed, 4 insertions(+), 118 deletions(-) delete mode 100644 src/legacy/ui/public/filters/__tests__/short_dots.js delete mode 100644 src/legacy/ui/public/filters/short_dots.js diff --git a/src/legacy/ui/public/directives/field_name.js b/src/legacy/ui/public/directives/field_name.js index 383d7cdc18e0c..4fb68fce6dad7 100644 --- a/src/legacy/ui/public/directives/field_name.js +++ b/src/legacy/ui/public/directives/field_name.js @@ -19,7 +19,7 @@ import $ from 'jquery'; import { template } from 'lodash'; -import '../filters/short_dots'; +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'; @@ -126,7 +126,9 @@ module.directive('fieldName', function ($compile, $rootScope, $filter, i18n) { const results = $scope.field ? !$scope.field.rowCount && !$scope.field.scripted : false; const scripted = $scope.field ? $scope.field.scripted : false; - const displayName = $filter('shortDots')(name); + + const isShortDots = this.getConfig('shortDots:enable'); + const displayName = isShortDots ? shortenDottedString(name) : name; $el .attr('title', name) diff --git a/src/legacy/ui/public/filters/__tests__/short_dots.js b/src/legacy/ui/public/filters/__tests__/short_dots.js deleted file mode 100644 index 747c2c280750e..0000000000000 --- a/src/legacy/ui/public/filters/__tests__/short_dots.js +++ /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. - */ - -import expect from '@kbn/expect'; -import ngMock from 'ng_mock'; -import 'plugins/kibana/discover/index'; -import '../short_dots'; - - -let filter; - -let config; - -const init = function () { - // Load the application - ngMock.module('kibana'); - - // Create the scope - ngMock.inject(function ($filter, _config_) { - config = _config_; - filter = $filter('shortDots'); - }); -}; - - -describe('shortDots filter', function () { - - beforeEach(function () { - init(); - }); - - it('should have a uriescape filter', function () { - expect(filter).to.not.be(null); - }); - - it('should shorten foo.bar.baz to f.b.baz when shortDots:enable is true', function () { - config.set('shortDots:enable', true); - expect(filter('foo.bar.baz')).to.be('f.b.baz'); - }); - - it('should not shorten when shortDots:enable is false', function () { - config.set('shortDots:enable', false); - expect(filter('foo.bar.baz')).to.be('foo.bar.baz'); - }); - - it('should not shorten floating point numbers in any case', function () { - config.set('shortDots:enable', false); - expect(filter(12345.6789)).to.be(12345.6789); - config.set('shortDots:enable', true); - expect(filter(12345.6789)).to.be(12345.6789); - }); - - -}); diff --git a/src/legacy/ui/public/filters/short_dots.js b/src/legacy/ui/public/filters/short_dots.js deleted file mode 100644 index 02a7672165c79..0000000000000 --- a/src/legacy/ui/public/filters/short_dots.js +++ /dev/null @@ -1,46 +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. - */ - -import _ from 'lodash'; -import { shortenDottedString } from '../../../core_plugins/kibana/common/utils/shorten_dotted_string'; -import { uiModules } from '../modules'; -// Shorts dot notated strings -// e.g., foo.bar.baz becomes f.b.baz -// 'foo.bar.baz'.replace(/(.+?\.)/g,function(v) {return v[0]+'.';}); - -uiModules - .get('kibana') - .filter('shortDots', function (Private) { - return Private(shortDotsFilterProvider); - }); - -function shortDotsFilterProvider(config) { - let filter; - - config.watch('shortDots:enable', updateFilter); - - return wrapper; - - function updateFilter(enabled) { - filter = enabled ? shortenDottedString : _.identity; - } - function wrapper(str) { - return filter(str); - } -} From f5c3223654811200d660b85848cb425b6d9f2045 Mon Sep 17 00:00:00 2001 From: Liza Katz Date: Sun, 7 Apr 2019 14:52:11 +0300 Subject: [PATCH 10/12] short dots adjustment --- .../discover/doc_table/components/table_header.html | 2 +- .../discover/doc_table/components/table_header.js | 12 +++++++++--- src/legacy/ui/public/directives/field_name.js | 4 ++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header.html b/src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header.html index 9a595b293254b..b254461f70429 100644 --- a/src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header.html +++ b/src/legacy/core_plugins/kibana/public/discover/doc_table/components/table_header.html @@ -29,7 +29,7 @@ - {{name | shortDots}} + {{getShortDotsName(name)}}