Skip to content

Commit 7ef672d

Browse files
[9.1] [Index Management] Fix data retention modal validation (elastic#240062) (elastic#240828)
# Backport This will backport the following commits from `main` to `9.1`: - [[Index Management] Fix data retention modal validation (elastic#240062)](elastic#240062) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Sonia Sanz Vivas","email":"[email protected]"},"sourceCommit":{"committedDate":"2025-10-27T14:03:02Z","message":"[Index Management] Fix data retention modal validation (elastic#240062)\n\nFixes https://github.com/elastic/kibana/issues/239656\n## Summary\n\nWe had a bug in the validation for data retention modal in data streams.\nThe data retention period field couldn't left blank even if the enable\ndata retention toggle was disabled or the keep data indefinitely\nenabled. To fix this, we need to re-validate the form whenever a form\nfield changes.\n\n### how to test\n\n- Open the edit data retention modal for some data stream\n- Toggle on `Enable data retention`, leave data retention period blank,\nlet `Keep data indefinitely` disabled.\n- Verify that you see the validation warning and you are not allowed to\nsave (this is ok!)\n<img width=\"739\" height=\"431\" alt=\"Screenshot 2025-10-22 at 13 13 07\"\nsrc=\"https://github.com/user-attachments/assets/c59cfb5e-d405-4176-9efd-46bf76a9332d\"\n/>\n\n- Now enable `Keep data indefinitely`. \n- The validation error should disappear and you should be allowed to\nsave (great!).\n \n<img width=\"748\" height=\"417\" alt=\"Screenshot 2025-10-22 at 13 13 13\"\nsrc=\"https://github.com/user-attachments/assets/aef71367-663d-4643-bf2e-de9072e7e854\"\n/>\n\n- Disable `Keep data indefinitely`, leave data retention period blank\nand toggle off `Enable data retention`\n- The validation error should disappear and you should be allowed to\nsave (great!).\n<img width=\"717\" height=\"394\" alt=\"Screenshot 2025-10-22 at 13 12 38\"\nsrc=\"https://github.com/user-attachments/assets/7ace405c-9877-4a36-ad52-d36a29eba437\"\n/>\n\nNote: the Save button won't be enabled unless the form is dirty.\n\n**Bonus track**: Fixed some accessibility warnings in the file by adding\naria-labels to the buttons.","sha":"57ff405bf4958951568fb90ff8e72c591d119b6a","branchLabelMapping":{"^v9.3.0$":"main","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Feature:Index Management","Team:Kibana Management","release_note:skip","backport:all-open","v9.3.0"],"title":"[Index Management] Fix data retention modal validation","number":240062,"url":"https://github.com/elastic/kibana/pull/240062","mergeCommit":{"message":"[Index Management] Fix data retention modal validation (elastic#240062)\n\nFixes https://github.com/elastic/kibana/issues/239656\n## Summary\n\nWe had a bug in the validation for data retention modal in data streams.\nThe data retention period field couldn't left blank even if the enable\ndata retention toggle was disabled or the keep data indefinitely\nenabled. To fix this, we need to re-validate the form whenever a form\nfield changes.\n\n### how to test\n\n- Open the edit data retention modal for some data stream\n- Toggle on `Enable data retention`, leave data retention period blank,\nlet `Keep data indefinitely` disabled.\n- Verify that you see the validation warning and you are not allowed to\nsave (this is ok!)\n<img width=\"739\" height=\"431\" alt=\"Screenshot 2025-10-22 at 13 13 07\"\nsrc=\"https://github.com/user-attachments/assets/c59cfb5e-d405-4176-9efd-46bf76a9332d\"\n/>\n\n- Now enable `Keep data indefinitely`. \n- The validation error should disappear and you should be allowed to\nsave (great!).\n \n<img width=\"748\" height=\"417\" alt=\"Screenshot 2025-10-22 at 13 13 13\"\nsrc=\"https://github.com/user-attachments/assets/aef71367-663d-4643-bf2e-de9072e7e854\"\n/>\n\n- Disable `Keep data indefinitely`, leave data retention period blank\nand toggle off `Enable data retention`\n- The validation error should disappear and you should be allowed to\nsave (great!).\n<img width=\"717\" height=\"394\" alt=\"Screenshot 2025-10-22 at 13 12 38\"\nsrc=\"https://github.com/user-attachments/assets/7ace405c-9877-4a36-ad52-d36a29eba437\"\n/>\n\nNote: the Save button won't be enabled unless the form is dirty.\n\n**Bonus track**: Fixed some accessibility warnings in the file by adding\naria-labels to the buttons.","sha":"57ff405bf4958951568fb90ff8e72c591d119b6a"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.3.0","branchLabelMappingKey":"^v9.3.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/240062","number":240062,"mergeCommit":{"message":"[Index Management] Fix data retention modal validation (elastic#240062)\n\nFixes https://github.com/elastic/kibana/issues/239656\n## Summary\n\nWe had a bug in the validation for data retention modal in data streams.\nThe data retention period field couldn't left blank even if the enable\ndata retention toggle was disabled or the keep data indefinitely\nenabled. To fix this, we need to re-validate the form whenever a form\nfield changes.\n\n### how to test\n\n- Open the edit data retention modal for some data stream\n- Toggle on `Enable data retention`, leave data retention period blank,\nlet `Keep data indefinitely` disabled.\n- Verify that you see the validation warning and you are not allowed to\nsave (this is ok!)\n<img width=\"739\" height=\"431\" alt=\"Screenshot 2025-10-22 at 13 13 07\"\nsrc=\"https://github.com/user-attachments/assets/c59cfb5e-d405-4176-9efd-46bf76a9332d\"\n/>\n\n- Now enable `Keep data indefinitely`. \n- The validation error should disappear and you should be allowed to\nsave (great!).\n \n<img width=\"748\" height=\"417\" alt=\"Screenshot 2025-10-22 at 13 13 13\"\nsrc=\"https://github.com/user-attachments/assets/aef71367-663d-4643-bf2e-de9072e7e854\"\n/>\n\n- Disable `Keep data indefinitely`, leave data retention period blank\nand toggle off `Enable data retention`\n- The validation error should disappear and you should be allowed to\nsave (great!).\n<img width=\"717\" height=\"394\" alt=\"Screenshot 2025-10-22 at 13 12 38\"\nsrc=\"https://github.com/user-attachments/assets/7ace405c-9877-4a36-ad52-d36a29eba437\"\n/>\n\nNote: the Save button won't be enabled unless the form is dirty.\n\n**Bonus track**: Fixed some accessibility warnings in the file by adding\naria-labels to the buttons.","sha":"57ff405bf4958951568fb90ff8e72c591d119b6a"}}]}] BACKPORT--> --------- Co-authored-by: Sonia Sanz Vivas <[email protected]>
1 parent 841910d commit 7ef672d

File tree

1 file changed

+19
-6
lines changed
  • x-pack/platform/plugins/shared/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal

1 file changed

+19
-6
lines changed

x-pack/platform/plugins/shared/index_management/public/application/sections/home/data_stream_list/edit_data_retention_modal/edit_data_retention_modal.tsx

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,11 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
9696
const formHasErrors = form.getErrors().length > 0;
9797
const disableSubmit = formHasErrors || !isDirty || form.isValid === false;
9898

99-
// Whenever the timeUnit field changes, we need to re-validate
99+
// Whenever a form data field changes, we need to re-validate
100100
// the dataRetention field
101101
useEffect(() => {
102-
if (formData.dataRetention) {
103-
form.validateFields(['dataRetention']);
104-
}
105-
}, [formData.timeUnit, form, formData.dataRetention]);
102+
form.validateFields(['dataRetention']);
103+
}, [form, formData]);
106104

107105
const onSubmitForm = async () => {
108106
const { isValid, data } = await form.submit();
@@ -202,6 +200,12 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
202200
onClose={() => onClose()}
203201
data-test-subj="editDataRetentionModal"
204202
css={{ width: 650 }}
203+
aria-label={i18n.translate(
204+
'xpack.idxMgmt.dataStreams.editDataRetentionModal.modalAriaLabel',
205+
{
206+
defaultMessage: 'Edit data retention modal',
207+
}
208+
)}
205209
>
206210
<Form form={form} data-test-subj="editDataRetentionForm">
207211
<EuiModalHeader>
@@ -395,7 +399,16 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
395399
</EuiModalBody>
396400

397401
<EuiModalFooter>
398-
<EuiButtonEmpty data-test-subj="cancelButton" onClick={() => onClose()}>
402+
<EuiButtonEmpty
403+
data-test-subj="cancelButton"
404+
onClick={() => onClose()}
405+
aria-label={i18n.translate(
406+
'xpack.idxMgmt.dataStreams.editDataRetentionModal.cancelButtonAriaLabel',
407+
{
408+
defaultMessage: 'Cancel editing data retention',
409+
}
410+
)}
411+
>
399412
<FormattedMessage
400413
id="xpack.idxMgmt.dataStreams.editDataRetentionModal.cancelButtonLabel"
401414
defaultMessage="Cancel"

0 commit comments

Comments
 (0)