Skip to content

fix: improve maintenance date-range sync and validation#7065

Open
prakash-218 wants to merge 2 commits intolouislam:masterfrom
prakash-218:enh-end-date-dynamic
Open

fix: improve maintenance date-range sync and validation#7065
prakash-218 wants to merge 2 commits intolouislam:masterfrom
prakash-218:enh-end-date-dynamic

Conversation

@prakash-218
Copy link

@prakash-218 prakash-218 commented Feb 28, 2026

Summary

In this pull request, the following changes are made:

  • updated the backend to reject if the end date is before the start date
  • in the frontend, made changes to
  • update the endtime, when start datetime is changed and a duration is picked
    
  • on updating the end date, the duration gets updated as well.
    
  • add utility functions to parse and format date-time
Please follow this checklist to avoid unnecessary back and forth (click to expand)
  • ⚠️ If there are Breaking change (a fix or feature that alters existing functionality in a way that could cause issues) I have called them out
  • 🧠 I have disclosed any use of LLMs/AI in this contribution and reviewed all generated content.
    I understand that I am responsible for and able to explain every line of code I submit.
  • 🔍 Any UI changes adhere to visual style of this project.
  • 🛠️ I have self-reviewed and self-tested my code to ensure it works as expected.
  • 📝 I have commented my code, especially in hard-to-understand areas (e.g., using JSDoc for methods).
  • 🤖 I added or updated automated tests where appropriate.
  • 📄 Documentation updates are included (if applicable).
  • 🧰 Dependency updates are listed and explained.
  • ⚠️ CI passes and is green.

Screenshots for Visual Changes

  • UI Modifications: Highlight any changes made to the user interface.
  • Before & After: Include screenshots or comparisons (if applicable).
Event Before After
creating/editing maintenance image image

@github-actions
Copy link
Contributor

Hello and thanks for lending a paw to Uptime Kuma! 🐻👋
As this is your first contribution, please be sure to check out our Pull Request guidelines.
In particular: - Mark your PR as Draft while you’re still making changes - Mark it as Ready for review once it’s fully ready
If you have any design or process questions, feel free to ask them right here in this pull request - unclear documentation is a bug too.

@prakash-218 prakash-218 marked this pull request as draft February 28, 2026 01:20
@prakash-218 prakash-218 changed the title Enh: improve maintenance date-range sync and validation Fix: improve maintenance date-range sync and validation Feb 28, 2026
@prakash-218 prakash-218 changed the title Fix: improve maintenance date-range sync and validation fix: improve maintenance date-range sync and validation Feb 28, 2026
@prakash-218 prakash-218 marked this pull request as ready for review February 28, 2026 01:23
@github-actions github-actions bot added the pr:needs review this PR needs a review by maintainers or other community members label Feb 28, 2026
@CommanderStorm CommanderStorm requested a review from Copilot March 5, 2026 06:17
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_date is before start_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 to src/lang/en.json so 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

  • endDateManuallyEdited is only set when both oldEnd and newEnd are 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 makes newEnd falsy, then the next change makes oldEnd falsy). That can cause subsequent start-date edits to unexpectedly keep auto-updating the end date. Consider treating any user-driven change (when not isUpdatingEndDateProgrammatically) as manual, while still ignoring the initial value population during init()/data load.
        singleEndDate(newEnd, oldEnd) {
            if (this.maintenance.strategy !== "single") {
                return;
            }

            if (!oldEnd || !newEnd || this.isUpdatingEndDateProgrammatically) {
                return;
            }

            this.endDateManuallyEdited = true;
        },

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

Labels

pr:needs review this PR needs a review by maintainers or other community members

Projects

None yet

Development

Successfully merging this pull request may close these issues.

On the maintenance creation form, link start and end times together

2 participants