Skip to content

Fix/maintenance recurring edit validation#3547

Open
ZeinebMegaadi wants to merge 2 commits intobluewave-labs:developfrom
ZeinebMegaadi:fix/maintenance-recurring-edit-validation
Open

Fix/maintenance recurring edit validation#3547
ZeinebMegaadi wants to merge 2 commits intobluewave-labs:developfrom
ZeinebMegaadi:fix/maintenance-recurring-edit-validation

Conversation

@ZeinebMegaadi
Copy link
Copy Markdown
Contributor

(Please remove this line only before submitting your PR. Ensure that all relevant items are checked before submission.)

Describe your changes

When editing a repeating maintenance window whose first occurrence has already passed, the form validation rejected the existing start date with "Start date and time must be in the future", making it impossible to save any edits.
The fix extracts the base object schema into maintenanceWindowBaseSchema and derives two schemas from it: maintenanceWindowSchema (with the future date refine, used on create) and maintenanceWindowEditSchema (without it, used on edit). Since one-time windows are auto-deleted by MongoDB's TTL index once they expire, skipping the future date check in edit mode is safe for all cases.

Write your issue number after "Fixes "

Fixes #3546

Please ensure all items are checked off before requesting a review. "Checked off" means you need to add an "x" character between brackets so they turn into checkmarks.

  • (Do not skip this or your PR will be closed) I deployed the application locally.
  • (Do not skip this or your PR will be closed) I have performed a self-reviewing and testing of my code.
  • I have included the issue # in the PR.
  • I have added i18n support to visible strings (instead of <div>Add</div>, use):
const { t } = useTranslation();
<div>{t('add')}</div>
  • I have not included any files that are not related to my pull request, including package-lock and package-json if dependencies have not changed
  • I didn't use any hardcoded values (otherwise it will not scale, and will make it difficult to maintain consistency across the application).
  • I made sure font sizes, color choices etc are all referenced from the theme. I don't have any hardcoded dimensions.
  • My PR is granular and targeted to one specific feature.
  • There are two database implementations (MongoDB and PostgreSQL TimescaleDB) and I have taken care of them appropriately.
  • I ran npm run format in server and client directories, which automatically formats your code.
  • I took a screenshot or a video and attached to this PR if there is a UI change.

@ZeinebMegaadi
Copy link
Copy Markdown
Contributor Author

This fix happens after any edit and not specifically for repeating windows though I'm not sure if it's okay to be kept this way or if I should restrict it to only repeating windows. Do let me know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cannot edit recurring maintenance window after first occurrence due to "start date must be in the future" validation

1 participant