From f95bbd7221f581b5aef743f05b9706f985b4ac55 Mon Sep 17 00:00:00 2001 From: Elena Stoeva Date: Thu, 12 Dec 2024 16:27:03 +0000 Subject: [PATCH] Add some fixes --- .../edit_data_retention_modal.tsx | 29 +++++++++++-------- .../translations/translations/fr-FR.json | 7 +++++ .../translations/translations/ja-JP.json | 7 +++++ .../translations/translations/zh-CN.json | 6 ++++ 4 files changed, 37 insertions(+), 12 deletions(-) diff --git a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx index e88c25a487df1..8b7fa7a58f669 100644 --- a/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx +++ b/x-pack/plugins/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx @@ -59,6 +59,7 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ isBulkEdit, }) => { const lifecycle = dataStreams[0]?.lifecycle; + const isSingleDataStream = dataStreams.length === 1; const { history, @@ -66,9 +67,9 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ } = useAppContext(); const dataStreamNames = dataStreams.map(({ name }: DataStream) => name as string); const globalMaxRetention = deserializeGlobalMaxRetention(lifecycle?.globalMaxRetention); - const { size, unit } = isBulkEdit - ? { size: undefined, unit: undefined } - : splitSizeAndUnits(lifecycle?.data_retention as string); + const { size, unit } = isSingleDataStream + ? splitSizeAndUnits(lifecycle?.data_retention as string) + : { size: undefined, unit: undefined }; const { services: { notificationService }, @@ -79,11 +80,12 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ defaultValue: { dataRetention: size, timeUnit: unit || 'd', - dataRetentionEnabled: isBulkEdit ? true : lifecycle?.enabled, + dataRetentionEnabled: isSingleDataStream ? lifecycle?.enabled : true, // When data retention is not set and lifecycle is enabled, is the only scenario in // which data retention will be infinite. If lifecycle isnt set or is not enabled, we // dont have inifinite data retention. - infiniteRetentionPeriod: !isBulkEdit && lifecycle?.enabled && !lifecycle?.data_retention, + infiniteRetentionPeriod: + isSingleDataStream && lifecycle?.enabled && !lifecycle?.data_retention, }, schema: editDataRetentionFormSchema, id: 'editDataRetentionForm', @@ -179,11 +181,14 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ (ds: DataStream) => formData.dataRetention && formData.timeUnit && - ((typeof ds.lifecycle?.data_retention === 'string' && - isRetentionBiggerThan( - ds.lifecycle.data_retention, - `${formData.dataRetention}${formData.timeUnit}` - )) || + ((ds.lifecycle?.enabled && + !ds.lifecycle?.data_retention && + !ds.lifecycle?.effective_retention) || + (typeof ds.lifecycle?.data_retention === 'string' && + isRetentionBiggerThan( + ds.lifecycle.data_retention, + `${formData.dataRetention}${formData.timeUnit}` + )) || (ds.lifecycle?.effective_retention && isRetentionBiggerThan( ds.lifecycle.effective_retention, @@ -203,7 +208,7 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ @@ -265,7 +270,7 @@ export const EditDataRetentionModal: React.FunctionComponent = ({ } helpText={ isBulkEdit && - globalMaxRetention && ( + lifecycle?.globalMaxRetention && (