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

[Index Management] Fix unhandled error in ds data retention modal #196524

Merged
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,12 @@ const configurationFormSchema: FormSchema = {
// If project level data retention is enabled, we need to enforce the global max retention
const { globalMaxRetention, enableProjectLevelRetentionChecks } = customData.value as any;
if (enableProjectLevelRetentionChecks) {
const currentValue = `${value}${formData.timeUnit}`;
if (globalMaxRetention && isRetentionBiggerThan(currentValue, globalMaxRetention)) {
if (
value &&
formData.timeUnit &&
globalMaxRetention &&
isRetentionBiggerThan(`${value}${formData.timeUnit}`, globalMaxRetention)
) {
return {
message: i18n.translate(
'xpack.idxMgmt.dataStreamsDetailsPanel.editDataRetentionModal.dataRetentionFieldMaxError',
Expand Down Expand Up @@ -258,11 +262,11 @@ export const EditDataRetentionModal: React.FunctionComponent<Props> = ({
const formHasErrors = form.getErrors().length > 0;
const disableSubmit = formHasErrors || !isDirty || form.isValid === false;

// Whenever the formData changes, we need to re-validate the dataRetention field
// as it depends on the timeUnit field.
// Whenever the dataRetention or timeUnit field changes, we need to re-validate
// the dataRetention field
useEffect(() => {
form.validateFields(['dataRetention']);
}, [formData, form]);
}, [formData.dataRetention, formData.timeUnit, form]);

const onSubmitForm = async () => {
const { isValid, data } = await form.submit();
Expand Down