From 42dd594854fdf57eb7a85ba4cd38c613dfbf5a66 Mon Sep 17 00:00:00 2001 From: Maja Grubic Date: Mon, 30 Sep 2019 13:36:56 +0100 Subject: [PATCH] Adding gte and lt symbols in range filter fileds and popup (#46697) (#46895) --- .../ui/public/agg_types/__tests__/buckets/_range.js | 6 +++--- .../__tests__/buckets/create_filter/range.js | 2 +- src/legacy/ui/public/agg_types/buckets/range.js | 10 +++++++--- .../public/vis/editors/default/controls/ranges.tsx | 12 ++++++++++++ .../visualize/loader/pipeline_helpers/utilities.ts | 6 +++++- test/functional/apps/visualize/_data_table.js | 12 ++++++------ x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 8 files changed, 34 insertions(+), 16 deletions(-) diff --git a/src/legacy/ui/public/agg_types/__tests__/buckets/_range.js b/src/legacy/ui/public/agg_types/__tests__/buckets/_range.js index b79687caf6e8d..e47802aa6f4bf 100644 --- a/src/legacy/ui/public/agg_types/__tests__/buckets/_range.js +++ b/src/legacy/ui/public/agg_types/__tests__/buckets/_range.js @@ -62,9 +62,9 @@ describe('Range Agg', function () { const format = function (val) { return agg.fieldFormatter()(agg.getKey(val)); }; - expect(format(buckets[0])).to.be('-∞ to 1 KB'); - expect(format(buckets[1])).to.be('1 KB to 2.5 KB'); - expect(format(buckets[2])).to.be('2.5 KB to +∞'); + expect(format(buckets[0])).to.be('≥ -∞ and < 1 KB'); + expect(format(buckets[1])).to.be('≥ 1 KB and < 2.5 KB'); + expect(format(buckets[2])).to.be('≥ 2.5 KB and < +∞'); }); }); diff --git a/src/legacy/ui/public/agg_types/__tests__/buckets/create_filter/range.js b/src/legacy/ui/public/agg_types/__tests__/buckets/create_filter/range.js index 8b79154cdef20..228fd6bce5cfb 100644 --- a/src/legacy/ui/public/agg_types/__tests__/buckets/create_filter/range.js +++ b/src/legacy/ui/public/agg_types/__tests__/buckets/create_filter/range.js @@ -60,7 +60,7 @@ describe('AggConfig Filters', function () { expect(filter.range).to.have.property('bytes'); expect(filter.range.bytes).to.have.property('gte', 1024.0); expect(filter.range.bytes).to.have.property('lt', 2048.0); - expect(filter.meta).to.have.property('formattedValue', '1,024 to 2,048'); + expect(filter.meta).to.have.property('formattedValue', '≥ 1,024 and < 2,048'); }); }); }); diff --git a/src/legacy/ui/public/agg_types/buckets/range.js b/src/legacy/ui/public/agg_types/buckets/range.js index 66bdf4e1d3a12..89d553cd1c625 100644 --- a/src/legacy/ui/public/agg_types/buckets/range.js +++ b/src/legacy/ui/public/agg_types/buckets/range.js @@ -66,12 +66,16 @@ export const rangeBucketAgg = new BucketAggType({ const RangeFormat = FieldFormat.from(function (range) { const format = agg.fieldOwnFormatter(); + const gte = '\u2265'; + const lt = '\u003c'; return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { - defaultMessage: '{from} to {to}', + defaultMessage: '{gte} {from} and {lt} {to}', values: { + gte, from: format(range.gte), - to: format(range.lt) - } + lt, + to: format(range.lt), + }, }); }); diff --git a/src/legacy/ui/public/vis/editors/default/controls/ranges.tsx b/src/legacy/ui/public/vis/editors/default/controls/ranges.tsx index 2b551a80c2479..b238d1124528d 100644 --- a/src/legacy/ui/public/vis/editors/default/controls/ranges.tsx +++ b/src/legacy/ui/public/vis/editors/default/controls/ranges.tsx @@ -153,6 +153,16 @@ function RangesParamEditor({ [isFromValid, isToValid] = validateRange({ from, to }, index); } + const fromPrepend = i18n.translate( + 'common.ui.aggTypes.ranges.greaterThanOrEqualPrepend', + { + defaultMessage: '\u2265', + } + ); + const toPrepend = i18n.translate('common.ui.aggTypes.ranges.lessThanPrepend', { + defaultMessage: '\u003c', + }); + return ( @@ -168,6 +178,7 @@ function RangesParamEditor({ fullWidth={true} compressed={true} isInvalid={!isFromValid} + prepend={fromPrepend} /> @@ -185,6 +196,7 @@ function RangesParamEditor({ fullWidth={true} compressed={true} isInvalid={!isToValid} + prepend={toPrepend} /> diff --git a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts index 96d9af0cf9077..29c3caed2f7dd 100644 --- a/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts +++ b/src/legacy/ui/public/visualize/loader/pipeline_helpers/utilities.ts @@ -99,10 +99,14 @@ export const getFormat: FormatFactory = (mapping = {}) => { if (id === 'range') { const RangeFormat = FieldFormat.from((range: any) => { const format = getFieldFormat(id, mapping.params); + const gte = '\u2265'; + const lt = '\u003c'; return i18n.translate('common.ui.aggTypes.buckets.ranges.rangesFormatMessage', { - defaultMessage: '{from} to {to}', + defaultMessage: '{gte} {from} and {lt} {to}', values: { + gte, from: format.convert(range.gte), + lt, to: format.convert(range.lt), }, }); diff --git a/test/functional/apps/visualize/_data_table.js b/test/functional/apps/visualize/_data_table.js index 745bb25775694..b540c1e949fbc 100644 --- a/test/functional/apps/visualize/_data_table.js +++ b/test/functional/apps/visualize/_data_table.js @@ -101,9 +101,9 @@ export default function ({ getService, getPageObjects }) { async function expectValidTableData() { const data = await PageObjects.visualize.getTableVisData(); expect(data.trim().split('\n')).to.be.eql([ - '0 to 1000', + '≥ 0 and < 1000', '1,351 64.7%', - '1000 to 2000', + '≥ 1000 and < 2000', '737 35.3%', ]); } @@ -146,9 +146,9 @@ export default function ({ getService, getPageObjects }) { const data = await PageObjects.visualize.getTableVisData(); expect(data.trim().split('\n')).to.be.eql([ - '0 to 1000', + '≥ 0 and < 1000', '344.094B', - '1000 to 2000', + '≥ 1000 and < 2000', '1.697KB', ]); }); @@ -248,8 +248,8 @@ export default function ({ getService, getPageObjects }) { await PageObjects.visualize.clickGo(); const data = await PageObjects.visualize.getTableVisData(); expect(data.trim().split('\n')).to.be.eql([ - '0 to 1000', '1,351', - '1000 to 2000', '737', + '≥ 0 and < 1000', '1,351', + '≥ 1000 and < 2000', '737', ]); }); diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 0a6a0f0adb446..d656ff273a4c6 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -102,7 +102,6 @@ "common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName": "1 年ごと", "common.ui.aggTypes.buckets.ipRangeLabel": "{fieldName} IP 範囲", "common.ui.aggTypes.buckets.ipRangeTitle": "IPv4 範囲", - "common.ui.aggTypes.buckets.ranges.rangesFormatMessage": "{from} ~ {to}", "common.ui.aggTypes.buckets.rangesLabel": "{fieldName} の範囲", "common.ui.aggTypes.buckets.rangeTitle": "範囲", "common.ui.aggTypes.buckets.significantTerms.excludeLabel": "除外", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index 9b690723df9f8..7bcabe581fe77 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -102,7 +102,6 @@ "common.ui.aggTypes.buckets.intervalOptions.yearlyDisplayName": "每年", "common.ui.aggTypes.buckets.ipRangeLabel": "{fieldName} IP 范围", "common.ui.aggTypes.buckets.ipRangeTitle": "IPv4 范围", - "common.ui.aggTypes.buckets.ranges.rangesFormatMessage": "{from} 至 {to}", "common.ui.aggTypes.buckets.rangesLabel": "{fieldName} 范围", "common.ui.aggTypes.buckets.rangeTitle": "范围", "common.ui.aggTypes.buckets.significantTerms.excludeLabel": "排除",