From 4ddd0f9bada228324d50ced6595c6ff0b39acf94 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 11:49:54 +0100 Subject: [PATCH 01/10] removed an unnecessary tooltip in rollover field, added a tooltip to min age field when rollover is enabled --- .../components/phases/hot_phase/hot_phase.tsx | 25 ++++------------ .../min_age_field/min_age_field.tsx | 30 +++++++++++++++++-- 2 files changed, 34 insertions(+), 21 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx index c77493476b929..912a31673ad9d 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx @@ -121,25 +121,12 @@ export const HotPhase: FunctionComponent = () => {
path="_meta.hot.customRollover.enabled"> {(field) => ( - <> - field.setValue(e.target.checked)} - data-test-subj="rolloverSwitch" - /> -   - - } - /> - + field.setValue(e.target.checked)} + data-test-subj="rolloverSwitch" + /> )} {isUsingRollover && ( diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 2f1a058f5a943..4e7b98ad87a8d 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -17,11 +17,12 @@ import { EuiFormRow, EuiSelect, EuiText, + EuiIconTip, } from '@elastic/eui'; import { getFieldValidityAndErrorMessage } from '../../../../../../../shared_imports'; -import { UseField } from '../../../../form'; +import { UseField, useConfigurationIssues } from '../../../../form'; import { getUnitsAriaLabelForPhase, getTimingLabelForPhase } from './util'; @@ -62,6 +63,13 @@ const i18nTexts = { defaultMessage: 'nanoseconds', } ), + rolloverToolTipDescription: i18n.translate( + 'xpack.indexLifecycleMgt.editPolicy.minimumAge.rolloverToolTipDescription', + { + defaultMessage: + 'Data age is calculated as time from rollover. Rollover is configured in the hot phase.', + } + ), }; interface Props { @@ -69,6 +77,7 @@ interface Props { } export const MinAgeField: FunctionComponent = ({ phase }): React.ReactElement => { + const { isUsingRollover } = useConfigurationIssues(); return ( {(field) => { @@ -110,6 +119,23 @@ export const MinAgeField: FunctionComponent = ({ phase }): React.ReactEle const { isInvalid: isUnitFieldInvalid } = getFieldValidityAndErrorMessage( unitField ); + const selectAppendValue: Array = [ + i18n.translate( + 'xpack.indexLifecycleMgt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', + { defaultMessage: 'old' } + ), + ].concat( + isUsingRollover + ? [ + , + ] + : ([] as any[]) + ); return ( = ({ phase }): React.ReactEle unitField.setValue(e.target.value); }} isInvalid={isUnitFieldInvalid} - append={'old'} + append={selectAppendValue} data-test-subj={`${phase}-selectedMinimumAgeUnits`} aria-label={getUnitsAriaLabelForPhase(phase)} options={[ From 397c8b097db3e42c5fe338739fef3251723f3e1a Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 12:08:29 +0100 Subject: [PATCH 02/10] slight update to copy, added jest test and added comment about testing --- .../edit_policy/edit_policy.helpers.tsx | 6 +++ .../edit_policy/edit_policy.test.ts | 47 +++++++++++++++++++ .../min_age_field/min_age_field.tsx | 17 ++++--- 3 files changed, 63 insertions(+), 7 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx index 7e1b7c5267a8b..83a13f0523a40 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.helpers.tsx @@ -271,6 +271,9 @@ export const setup = async (arg?: { appServicesContext: Partial (): boolean => + exists(`${phase}-rolloverMinAgeInputIconTip`); + return { ...testBed, actions: { @@ -306,6 +309,7 @@ export const setup = async (arg?: { appServicesContext: Partial exists('phaseErrorIndicator-warm'), + hasRolloverTipOnMinAge: hasRolloverTipOnMinAge('warm'), ...createShrinkActions('warm'), ...createForceMergeActions('warm'), setReadonly: setReadonly('warm'), @@ -321,11 +325,13 @@ export const setup = async (arg?: { appServicesContext: Partial exists('phaseErrorIndicator-cold'), + hasRolloverTipOnMinAge: hasRolloverTipOnMinAge('cold'), ...createIndexPriorityActions('cold'), ...createSearchableSnapshotActions('cold'), }, delete: { ...createToggleDeletePhaseActions(), + hasRolloverTipOnMinAge: hasRolloverTipOnMinAge('delete'), setMinAgeValue: setMinAgeValue('delete'), setMinAgeUnits: setMinAgeUnits('delete'), }, diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts index 6f325084938e8..f1a15d805faf8 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/edit_policy/edit_policy.test.ts @@ -769,6 +769,38 @@ describe('', () => { }); }); }); + describe('with rollover', () => { + beforeEach(async () => { + httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]); + httpRequestsMockHelpers.setListNodes({ + isUsingDeprecatedDataRoleConfig: false, + nodesByAttributes: { test: ['123'] }, + nodesByRoles: { data: ['123'] }, + }); + httpRequestsMockHelpers.setListSnapshotRepos({ repositories: ['abc'] }); + httpRequestsMockHelpers.setLoadSnapshotPolicies([]); + + await act(async () => { + testBed = await setup(); + }); + + const { component } = testBed; + component.update(); + }); + + test('shows rollover tip on minimum age', async () => { + const { actions } = testBed; + + await actions.warm.enable(true); + await actions.cold.enable(true); + await actions.delete.enablePhase(); + + expect(actions.warm.hasRolloverTipOnMinAge()).toBeTruthy(); + expect(actions.cold.hasRolloverTipOnMinAge()).toBeTruthy(); + expect(actions.delete.hasRolloverTipOnMinAge()).toBeTruthy(); + }); + }); + describe('without rollover', () => { beforeEach(async () => { httpRequestsMockHelpers.setLoadPolicies([getDefaultHotPhasePolicy('my_policy')]); @@ -778,6 +810,7 @@ describe('', () => { nodesByRoles: { data: ['123'] }, }); httpRequestsMockHelpers.setListSnapshotRepos({ repositories: ['found-snapshots'] }); + httpRequestsMockHelpers.setLoadSnapshotPolicies([]); await act(async () => { testBed = await setup({ @@ -799,6 +832,20 @@ describe('', () => { expect(actions.hot.searchableSnapshotsExists()).toBeFalsy(); expect(actions.cold.searchableSnapshotDisabledDueToRollover()).toBeTruthy(); }); + + test('hiding rollover tip on minimum age', async () => { + const { actions } = testBed; + await actions.hot.toggleDefaultRollover(false); + await actions.hot.toggleRollover(false); + + await actions.warm.enable(true); + await actions.cold.enable(true); + await actions.delete.enablePhase(); + + expect(actions.warm.hasRolloverTipOnMinAge()).toBeFalsy(); + expect(actions.cold.hasRolloverTipOnMinAge()).toBeFalsy(); + expect(actions.delete.hasRolloverTipOnMinAge()).toBeFalsy(); + }); }); describe('policy timeline', () => { diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 4e7b98ad87a8d..cc9a07396c0aa 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -67,7 +67,7 @@ const i18nTexts = { 'xpack.indexLifecycleMgt.editPolicy.minimumAge.rolloverToolTipDescription', { defaultMessage: - 'Data age is calculated as time from rollover. Rollover is configured in the hot phase.', + 'Data age is calculated from rollover. Rollover is configured in the hot phase.', } ), }; @@ -127,12 +127,15 @@ export const MinAgeField: FunctionComponent = ({ phase }): React.ReactEle ].concat( isUsingRollover ? [ - , + <> + {/* This element is rendered for testing purposes only */} +
+ + , ] : ([] as any[]) ); From f21ad5bfb272531d16fe7efc65c70c5d081b3dc5 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 12:09:00 +0100 Subject: [PATCH 03/10] page title and timeline title to sentence case --- .../sections/edit_policy/components/timeline/timeline.tsx | 2 +- .../public/application/sections/edit_policy/edit_policy.tsx | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx index 8097ab51eb59e..f6067d2c5dda2 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx @@ -47,7 +47,7 @@ const SCORE_BUFFER_AMOUNT = 50; const i18nTexts = { title: i18n.translate('xpack.indexLifecycleMgmt.timeline.title', { - defaultMessage: 'Policy Summary', + defaultMessage: 'Policy summary', }), description: i18n.translate('xpack.indexLifecycleMgmt.timeline.description', { defaultMessage: 'This policy moves data through the following phases.', diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx index 0c7b5565372a5..637fbd893aaa0 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/edit_policy.tsx @@ -142,10 +142,10 @@ export const EditPolicy: React.FunctionComponent = ({ history }) => {

{isNewPolicy ? i18n.translate('xpack.indexLifecycleMgmt.editPolicy.createPolicyMessage', { - defaultMessage: 'Create Policy', + defaultMessage: 'Create policy', }) : i18n.translate('xpack.indexLifecycleMgmt.editPolicy.editPolicyMessage', { - defaultMessage: 'Edit Policy {originalPolicyName}', + defaultMessage: 'Edit policy {originalPolicyName}', values: { originalPolicyName }, })}

From 1c980b47e0d87faf11f784ce32332fade2ce6cd8 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 12:13:17 +0100 Subject: [PATCH 04/10] added link to learn more about timing to phase timeline component --- .../sections/edit_policy/components/index.ts | 1 + .../components/timeline/timeline.tsx | 20 +++++++++++-------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/index.ts b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/index.ts index dc4f1e31d3696..ccc553c58e899 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/index.ts +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/index.ts @@ -13,4 +13,5 @@ export { FieldLoadingError } from './field_loading_error'; export { Timeline } from './timeline'; export { FormErrorsCallout } from './form_errors_callout'; export { PhaseFooter } from './phase_footer'; +export { InfinityIcon } from './infinity_icon'; export * from './phases'; diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx index f6067d2c5dda2..c996c45171d2f 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/timeline/timeline.tsx @@ -6,6 +6,7 @@ */ import { i18n } from '@kbn/i18n'; +import { FormattedMessage } from '@kbn/i18n/react'; import React, { FunctionComponent, memo } from 'react'; import { EuiFlexGroup, EuiFlexItem, EuiTitle, EuiText, EuiIconTip } from '@elastic/eui'; @@ -18,7 +19,7 @@ import { AbsoluteTimings, } from '../../lib'; -import { InfinityIcon } from '../infinity_icon'; +import { InfinityIcon, LearnMoreLink } from '..'; import { TimelinePhaseText } from './components'; @@ -55,13 +56,6 @@ const i18nTexts = { hotPhase: i18n.translate('xpack.indexLifecycleMgmt.timeline.hotPhaseSectionTitle', { defaultMessage: 'Hot phase', }), - rolloverTooltip: i18n.translate( - 'xpack.indexLifecycleMgmt.timeline.hotPhaseRolloverToolTipContent', - { - defaultMessage: - 'How long it takes to reach the rollover criteria in the hot phase can vary. Data moves to the next phase when the time since rollover reaches the minimum age.', - } - ), warmPhase: i18n.translate('xpack.indexLifecycleMgmt.timeline.warmPhaseSectionTitle', { defaultMessage: 'Warm phase', }), @@ -143,6 +137,16 @@ export const Timeline: FunctionComponent = memo( {i18nTexts.description} +   + + } + /> From 7a5e283833f788db59d8adcb11be037182221858 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 12:15:14 +0100 Subject: [PATCH 05/10] fix jest test copy --- .../__jest__/client_integration/app/app.test.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts index 38cfad1a3b188..36f04be3b30b1 100644 --- a/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts +++ b/x-pack/plugins/index_lifecycle_management/__jest__/client_integration/app/app.test.ts @@ -22,8 +22,8 @@ const PERCENT_SIGN_NAME = 'test%'; const PERCENT_SIGN_WITH_OTHER_CHARS_NAME = 'test%#'; const PERCENT_SIGN_25_SEQUENCE = 'test%25'; -const createPolicyTitle = 'Create Policy'; -const editPolicyTitle = 'Edit Policy'; +const createPolicyTitle = 'Create policy'; +const editPolicyTitle = 'Edit policy'; window.scrollTo = jest.fn(); From 9240133e2f687deb730f1b967e643fc9c081facf Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 12:37:06 +0100 Subject: [PATCH 06/10] remove unused import --- .../edit_policy/components/phases/hot_phase/hot_phase.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx index 912a31673ad9d..6d4e2750bb2e8 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/hot_phase/hot_phase.tsx @@ -16,7 +16,6 @@ import { EuiCallOut, EuiTextColor, EuiSwitch, - EuiIconTip, EuiText, } from '@elastic/eui'; From 39b641e6fd80aa7324542a14aea95a69f75aa195 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 14:24:20 +0100 Subject: [PATCH 07/10] fix i18n --- .../phases/shared_fields/min_age_field/min_age_field.tsx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index cc9a07396c0aa..87c93eae381e4 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -64,7 +64,7 @@ const i18nTexts = { } ), rolloverToolTipDescription: i18n.translate( - 'xpack.indexLifecycleMgt.editPolicy.minimumAge.rolloverToolTipDescription', + 'xpack.indexLifecycleMgmt.editPolicy.minimumAge.rolloverToolTipDescription', { defaultMessage: 'Data age is calculated from rollover. Rollover is configured in the hot phase.', @@ -121,7 +121,7 @@ export const MinAgeField: FunctionComponent = ({ phase }): React.ReactEle ); const selectAppendValue: Array = [ i18n.translate( - 'xpack.indexLifecycleMgt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', + 'xpack.indexLifecycleMgmt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', { defaultMessage: 'old' } ), ].concat( From 41eefd867b9218499295b6315fa5cb6d8c40eac1 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 16:26:11 +0100 Subject: [PATCH 08/10] remove unused translations --- x-pack/plugins/translations/translations/ja-JP.json | 1 - x-pack/plugins/translations/translations/zh-CN.json | 1 - 2 files changed, 2 deletions(-) diff --git a/x-pack/plugins/translations/translations/ja-JP.json b/x-pack/plugins/translations/translations/ja-JP.json index 5e0bf7501eb11..47c1c3d746e88 100644 --- a/x-pack/plugins/translations/translations/ja-JP.json +++ b/x-pack/plugins/translations/translations/ja-JP.json @@ -9474,7 +9474,6 @@ "xpack.indexLifecycleMgmt.editPolicy.forcemerge.numberOfSegmentsRequiredError": "セグメント数の評価が必要です。", "xpack.indexLifecycleMgmt.editPolicy.formErrorsMessage": "このページのエラーを修正してください。", "xpack.indexLifecycleMgmt.editPolicy.hidePolicyJsonButto": "リクエストを非表示", - "xpack.indexLifecycleMgmt.editPolicy.hotPhase.enableRolloverTipContent": "現在のインデックスが定義された条件のいずれかを満たすときに、新しいインデックスにロールオーバーします。", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.learnAboutRolloverLinkText": "詳細", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.rolloverDefaultsTipContent": "インデックスが 30 日経過するか、50 GB に達したらロールオーバーします。", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.rolloverDescriptionMessage": "効率的なストレージと高いパフォーマンスのための時系列データの自動ロールアウト。", diff --git a/x-pack/plugins/translations/translations/zh-CN.json b/x-pack/plugins/translations/translations/zh-CN.json index d0dbd750853a2..bc7c3025c1a0e 100644 --- a/x-pack/plugins/translations/translations/zh-CN.json +++ b/x-pack/plugins/translations/translations/zh-CN.json @@ -9498,7 +9498,6 @@ "xpack.indexLifecycleMgmt.editPolicy.forcemerge.numberOfSegmentsRequiredError": "必须指定分段数的值。", "xpack.indexLifecycleMgmt.editPolicy.formErrorsMessage": "请修复此页面上的错误。", "xpack.indexLifecycleMgmt.editPolicy.hidePolicyJsonButto": "隐藏请求", - "xpack.indexLifecycleMgmt.editPolicy.hotPhase.enableRolloverTipContent": "在当前索引满足定义的条件之一时,滚动更新到新索引。", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.learnAboutRolloverLinkText": "了解详情", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.rolloverDefaultsTipContent": "当索引已存在 30 天或达到 50 GB 时滚动更新。", "xpack.indexLifecycleMgmt.editPolicy.hotPhase.rolloverDescriptionMessage": "自动滚动更新时间序列数据,以实现高效存储和更高性能。", From b48f7ea16b70fb0e69aec6abb331ac1ccc41d217 Mon Sep 17 00:00:00 2001 From: Jean-Louis Leysens Date: Thu, 11 Feb 2021 16:28:14 +0100 Subject: [PATCH 09/10] slight refactor to conditional for clarity --- .../min_age_field/min_age_field.tsx | 38 +++++++++---------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 87c93eae381e4..2f5b2e3da363b 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -70,6 +70,10 @@ const i18nTexts = { 'Data age is calculated from rollover. Rollover is configured in the hot phase.', } ), + ageUnitFieldSuffix: i18n.translate( + 'xpack.indexLifecycleMgmt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', + { defaultMessage: 'old' } + ), }; interface Props { @@ -119,26 +123,22 @@ export const MinAgeField: FunctionComponent = ({ phase }): React.ReactEle const { isInvalid: isUnitFieldInvalid } = getFieldValidityAndErrorMessage( unitField ); - const selectAppendValue: Array = [ - i18n.translate( - 'xpack.indexLifecycleMgmt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', - { defaultMessage: 'old' } - ), - ].concat( - isUsingRollover - ? [ - <> - {/* This element is rendered for testing purposes only */} -
- - , - ] - : ([] as any[]) + const icon = ( + <> + {/* This element is rendered for testing purposes only */} +
+ + ); + const selectAppendValue: Array< + string | React.ReactElement + > = isUsingRollover + ? [i18nTexts.ageUnitFieldSuffix, icon] + : [i18nTexts.ageUnitFieldSuffix]; return ( Date: Thu, 11 Feb 2021 16:29:43 +0100 Subject: [PATCH 10/10] slight refactor to i18n text naming --- .../phases/shared_fields/min_age_field/min_age_field.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx index 2f5b2e3da363b..04b756dc23559 100644 --- a/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx +++ b/x-pack/plugins/index_lifecycle_management/public/application/sections/edit_policy/components/phases/shared_fields/min_age_field/min_age_field.tsx @@ -70,7 +70,7 @@ const i18nTexts = { 'Data age is calculated from rollover. Rollover is configured in the hot phase.', } ), - ageUnitFieldSuffix: i18n.translate( + minAgeUnitFieldSuffix: i18n.translate( 'xpack.indexLifecycleMgmt.editPolicy.minimumAge.minimumAgeFieldSuffixLabel', { defaultMessage: 'old' } ), @@ -137,8 +137,8 @@ export const MinAgeField: FunctionComponent = ({ phase }): React.ReactEle const selectAppendValue: Array< string | React.ReactElement > = isUsingRollover - ? [i18nTexts.ageUnitFieldSuffix, icon] - : [i18nTexts.ageUnitFieldSuffix]; + ? [i18nTexts.minAgeUnitFieldSuffix, icon] + : [i18nTexts.minAgeUnitFieldSuffix]; return (