Prevent conversion of escalation start/end times to UTC (#2826)
# What this PR does Adds a boolean `convertToUTC` to the `TimeRange` component. For this use case on escalation chains since the user inputted fields are strings they will not be further converted to UTC and instead left as it is, which previously resulted in setting a wrong start/end combination. ## Which issue(s) this PR fixes https://github.com/grafana/oncall/issues/2781 ## Checklist - [ ] Unit, integration, and e2e (if applicable) tests updated - [ ] Documentation added (or `pr:no public docs` PR label added if not required) - [ ] `CHANGELOG.md` updated (or `pr:no changelog` PR label added if not required)
This commit is contained in:
parent
58a9a39efe
commit
3d396670c5
3 changed files with 9 additions and 9 deletions
|
|
@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||
### Changed
|
||||
|
||||
- Improve Grafana Alerting integration by @Ferril @teodosii ([#2742](https://github.com/grafana/oncall/pull/2742))
|
||||
- Fixed UTC conversion for escalation chain step of timerange
|
||||
([#2781](https://github.com/grafana/oncall/issues/2781))
|
||||
|
||||
## v1.3.24 (2023-08-17)
|
||||
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ class EscalationPolicy(OrderedModel):
|
|||
STEP_TRIGGER_CUSTOM_WEBHOOK: ("Trigger webhook {{custom_webhook}}", "Trigger webhook"),
|
||||
STEP_NOTIFY_USERS_QUEUE: ("Round robin notification for {{users}}", "Notify users one by one (round-robin)"),
|
||||
STEP_NOTIFY_IF_TIME: (
|
||||
"Continue escalation if current time is in {{timerange}}",
|
||||
"Continue escalation if current UTC time is in {{timerange}}",
|
||||
"Continue escalation if current time is in range",
|
||||
),
|
||||
STEP_NOTIFY_IF_NUM_ALERTS_IN_TIME_WINDOW: (
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ interface TimeRangeProps {
|
|||
}
|
||||
|
||||
function getMoments(from: string, to: string) {
|
||||
let fromMoment;
|
||||
let toMoment;
|
||||
let fromMoment: moment.Moment;
|
||||
let toMoment: moment.Moment;
|
||||
|
||||
if (!from || !to) {
|
||||
fromMoment = moment().startOf('hour');
|
||||
|
|
@ -29,18 +29,18 @@ function getMoments(from: string, to: string) {
|
|||
}
|
||||
} else {
|
||||
const [fh, fm] = from.split(':').map(Number);
|
||||
fromMoment = moment().utc().hour(fh).minute(fm).second(0).local();
|
||||
fromMoment = moment().hour(fh).minute(fm).second(0).local();
|
||||
|
||||
const [th, tm] = to.split(':').map(Number);
|
||||
toMoment = moment().utc().hour(th).minute(tm).second(0).local();
|
||||
toMoment = moment().hour(th).minute(tm).second(0).local();
|
||||
}
|
||||
|
||||
return [fromMoment, toMoment];
|
||||
}
|
||||
|
||||
function getRangeStrings(from: moment.Moment, to: moment.Moment) {
|
||||
const fromString = from.clone().utc().format('HH:mm:00');
|
||||
const toString = to.clone().utc().format('HH:mm:00');
|
||||
const fromString = from.clone().format('HH:mm:00');
|
||||
const toString = to.clone().format('HH:mm:00');
|
||||
|
||||
return [fromString, toString];
|
||||
}
|
||||
|
|
@ -48,9 +48,7 @@ function getRangeStrings(from: moment.Moment, to: moment.Moment) {
|
|||
const TimeRange = (props: TimeRangeProps) => {
|
||||
const { className, from: f, to: t, onChange, disabled } = props;
|
||||
|
||||
// @ts-ignore
|
||||
const [from, setFrom] = useState<moment.Moment>(getMoments(f, t)[0]);
|
||||
// @ts-ignore
|
||||
const [to, setTo] = useState<moment.Moment>(getMoments(f, t)[1]);
|
||||
|
||||
useEffect(() => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue