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

[7.x] Adding gte and lt symbols in range filter fileds and popup (#46697) #46895

Merged
merged 1 commit into from
Sep 30, 2019
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
6 changes: 3 additions & 3 deletions src/legacy/ui/public/agg_types/__tests__/buckets/_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 < +∞');

});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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');
});
});
});
10 changes: 7 additions & 3 deletions src/legacy/ui/public/agg_types/buckets/range.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
});
});

Expand Down
12 changes: 12 additions & 0 deletions src/legacy/ui/public/vis/editors/default/controls/ranges.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<Fragment key={id}>
<EuiFlexGroup gutterSize="s" alignItems="center" responsive={false}>
Expand All @@ -168,6 +178,7 @@ function RangesParamEditor({
fullWidth={true}
compressed={true}
isInvalid={!isFromValid}
prepend={fromPrepend}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand All @@ -185,6 +196,7 @@ function RangesParamEditor({
fullWidth={true}
compressed={true}
isInvalid={!isToValid}
prepend={toPrepend}
/>
</EuiFlexItem>
<EuiFlexItem grow={false}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
});
Expand Down
12 changes: 6 additions & 6 deletions test/functional/apps/visualize/_data_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -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%',
]);
}
Expand Down Expand Up @@ -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',
]);
});
Expand Down Expand Up @@ -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',
]);
});

Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/ja-JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "除外",
Expand Down
1 change: 0 additions & 1 deletion x-pack/plugins/translations/translations/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": "排除",
Expand Down