Allow editing of unscheduled downtimes that started over 48 hours ago #309
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #57
The main change is to the check of start dates older than 48 hours. This now (inelegantly) only applies when creating a new downtime, or when editing the start of a downtime, with more descriptive error messages added. This allows ongoing, unscheduled downtimes older than 48 hours to be edited (e.g. bringing the end date forward) but prevents the start date being changed once a downtime has been ongoing for 48 hours.
I have also added a check preventing editing of the end date into the past, as suggested in #57, although this feels slightly inconsistent, as it is currently possible to create downtimes that have finished.
This change does not allow editing of scheduled downtimes, as these cannot be edited in any way from 24 hours before they start. Allowing (limited) editing would be a much more substantial change. However, both scheduled and unscheduled downtimes can still be ended with immediate effect through a separate process.
This also has no effect on the creation of downtimes, so it is still not possible to create a downtime older than 48 hours, but this appears to be the intention of the check, and it would be straightforward to change this if desired.
More generally, I think more consistency in the validation would be useful, including (re)syncing the live validation of dates when editing a downtime to include all the current checks, and potentially reconsidering where all the different checks are handled within the code.
Note: Unfortunately, I will not be able to dedicate any significant time to further testing/responses, so I've made this a draft, but I think it worked as described, and thought it was worth sharing.