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

[8.x] [Index Management/Data Streams] Add warning callout in single edit data retention modal (#206760) #207112

Merged
merged 2 commits into from
Jan 24, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ export type TestSubjects =
| 'editDataRetentionButton'
| 'bulkEditDataRetentionButton'
| 'dataStreamActionsPopoverButton'
| 'reducedDataRetentionCallout'
| 'errorWhenCreatingCallout'
| 'manageDataStreamButton'
| 'dataRetentionValue'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -533,6 +533,30 @@ describe('Data Streams tab', () => {
testBed.component.update();
});

test('shows bulk edit callout for reduced data retention', async () => {
const {
actions: { selectDataStream, clickBulkEditDataRetentionButton },
} = testBed;

selectDataStream('dataStream1', true);
selectDataStream('dataStream2', true);

clickBulkEditDataRetentionButton();

// Decrease data retention value to 5d (it was 7d initially)
testBed.form.setInputValue('dataRetentionValue', '5');

// Verify that callout is displayed
expect(testBed.exists('reducedDataRetentionCallout')).toBeTruthy();

// Verify message in callout
const calloutText = testBed.find('reducedDataRetentionCallout').text();
expect(calloutText).toContain(
'The retention period will be reduced for 2 data streams. Data older than then new retention period will be permanently deleted.'
);
expect(calloutText).toContain('Affected data streams: dataStream1, dataStream2');
});

test('can set data retention period for mutliple data streams', async () => {
const {
actions: { selectDataStream, clickBulkEditDataRetentionButton },
Expand Down Expand Up @@ -796,6 +820,28 @@ describe('Data Streams tab', () => {
expect.objectContaining({ body: JSON.stringify({ dataStreams: ['dataStream1'] }) })
);
});

test('shows single edit callout for reduced data retention', async () => {
const {
actions: { clickNameAt, clickEditDataRetentionButton },
} = testBed;

await clickNameAt(0);

clickEditDataRetentionButton();

// Decrease data retention value to 5d (it was 7d initially)
testBed.form.setInputValue('dataRetentionValue', '5');

// Verify that callout is displayed
expect(testBed.exists('reducedDataRetentionCallout')).toBeTruthy();

// Verify message in callout
const calloutText = testBed.find('reducedDataRetentionCallout').text();
expect(calloutText).toContain(
'The retention period will be reduced. Data older than then new retention period will be permanently deleted.'
);
});
});

test('clicking index template name navigates to the index template details', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -201,16 +201,23 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
<EuiModal
onClose={() => onClose()}
data-test-subj="editDataRetentionModal"
css={{ minWidth: isBulkEdit ? 650 : 450, maxWidth: 650 }}
css={{ width: 650 }}
>
<Form form={form} data-test-subj="editDataRetentionForm">
<EuiModalHeader>
<EuiModalHeaderTitle>
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.modalTitleText"
defaultMessage="Edit data retention for {dataStreamCount} {dataStreamCount, plural, one {data stream} other {data streams}}"
values={{ dataStreamCount: dataStreams?.length }}
/>
{isBulkEdit ? (
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.bulkEdit.modalTitleText"
defaultMessage="Edit data retention for {dataStreamCount} {dataStreamCount, plural, one {data stream} other {data streams}}"
values={{ dataStreamCount: dataStreams?.length }}
/>
) : (
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.singleEdit.modalTitleText"
defaultMessage="Edit data retention"
/>
)}
</EuiModalHeaderTitle>
</EuiModalHeader>

Expand Down Expand Up @@ -292,7 +299,7 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
)
}
componentProps={{
fullWidth: isBulkEdit,
fullWidth: true,
euiFieldProps: {
disabled:
formData.infiniteRetentionPeriod ||
Expand Down Expand Up @@ -343,7 +350,7 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({

<EuiSpacer />

{isBulkEdit && affectedDataStreams.length > 0 && !formData.infiniteRetentionPeriod && (
{affectedDataStreams.length > 0 && !formData.infiniteRetentionPeriod && (
<EuiCallOut
title={i18n.translate(
'xpack.idxMgmt.dataStreams.editDataRetentionModal.affectedDataStreamsCalloutTitle',
Expand All @@ -353,18 +360,26 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
)}
color="danger"
iconType="warning"
data-test-subj="reducedDataRetentionCallout"
>
<p>
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.affectedDataStreamsCalloutText"
defaultMessage="The retention period will be reduced for {affectedDataStreamCount} data streams. Data older than then new
{isBulkEdit ? (
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.bulkEdit.affectedDataStreamsCalloutText"
defaultMessage="The retention period will be reduced for {affectedDataStreamCount} {affectedDataStreamCount, plural, one {data stream} other {data streams}}. Data older than then new
retention period will be permanently deleted."
values={{
affectedDataStreamCount: affectedDataStreams.length,
}}
/>
values={{
affectedDataStreamCount: affectedDataStreams.length,
}}
/>
) : (
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.singleEdit.affectedDataStreamsSingleCalloutText"
defaultMessage="The retention period will be reduced. Data older than then new retention period will be permanently deleted."
/>
)}
</p>
{affectedDataStreams.length <= 10 && (
{isBulkEdit && affectedDataStreams.length <= 10 && (
<p>
<FormattedMessage
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.affectedDataStreamsCalloutList"
Expand Down
Loading