fix: improve maintenance date-range sync and validation#7065
fix: improve maintenance date-range sync and validation#7065prakash-218 wants to merge 2 commits intolouislam:masterfrom
Conversation
|
Hello and thanks for lending a paw to Uptime Kuma! 🐻👋 |
There was a problem hiding this comment.
Pull request overview
This PR improves maintenance scheduling validation and UX by keeping the “single” maintenance start/end datetime fields in sync (unless the user manually overrides the end time) and by rejecting invalid date ranges on both frontend submit and backend model validation.
Changes:
- Add backend validation to reject maintenances where
end_dateis beforestart_date. - Update the maintenance edit/create UI to better sync end time when start time changes (and track “manual end edit” vs programmatic updates).
- Add backend tests covering valid/invalid single-maintenance date ranges.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
server/model/maintenance.js |
Adds server-side date-range ordering validation in jsonToBean. |
src/pages/EditMaintenance.vue |
Adds date parsing/formatting helpers, start/end sync watchers, and client-side submit validation for invalid ranges. |
test/backend-test/test-maintenance.js |
Adds unit tests for Maintenance.jsonToBean() date-range validation behavior. |
Comments suppressed due to low confidence (2)
src/pages/EditMaintenance.vue:935
- This toast error message is hard-coded and bypasses the app’s i18n pattern used elsewhere in this file (e.g., other
toastError(this.$t(...))calls). Please switch this to a$t(...)translation key and add the key tosrc/lang/en.jsonso the validation error is localizable.
if (this.hasInvalidDateRange) {
this.$root.toastError("End date must be after start date");
this.processing = false;
return;
src/pages/EditMaintenance.vue:687
endDateManuallyEditedis only set when botholdEndandnewEndare truthy. If the user clears the end datetime and then sets a new one, this watcher will never mark the end date as manually edited (clear makesnewEndfalsy, then the next change makesoldEndfalsy). That can cause subsequent start-date edits to unexpectedly keep auto-updating the end date. Consider treating any user-driven change (when notisUpdatingEndDateProgrammatically) as manual, while still ignoring the initial value population duringinit()/data load.
singleEndDate(newEnd, oldEnd) {
if (this.maintenance.strategy !== "single") {
return;
}
if (!oldEnd || !newEnd || this.isUpdatingEndDateProgrammatically) {
return;
}
this.endDateManuallyEdited = true;
},
Summary
In this pull request, the following changes are made:
Please follow this checklist to avoid unnecessary back and forth (click to expand)
I understand that I am responsible for and able to explain every line of code I submit.
Screenshots for Visual Changes
creating/editing maintenance