From 5f73af19f0b065d31e2563f1f61198b67f097ab7 Mon Sep 17 00:00:00 2001 From: Matias Bordese Date: Fri, 23 Jun 2023 13:29:36 -0300 Subject: [PATCH] Minor updates to schedule rotation form and preview (#2316) - When editing a shift, use `shiftStart` as `rotationStart` value (originally, `rotationStart` was most of the time the timestamp of creation, which is confusing in the new form; otoh, for newly created shifts, the `shiftStart` will match `rotationStart`) - Since shift preview is requested starting the day before the start of the week, sometimes the displayed preview is missing the last day of the week (preview returns 7 days by default) --- CHANGELOG.md | 5 +++++ .../src/containers/RotationForm/RotationForm.tsx | 7 ++++--- grafana-plugin/src/models/schedule/schedule.ts | 2 +- 3 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index aef3a338d9..fcbe375615 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - UI Updates for the integrations page ([#2310](https://github.com/grafana/oncall/pull/2310)) +- Prefer shift start when displaying rotation start value for existing shifts ([#2316](https://github.com/grafana/oncall/pull/2316)) + +### Fixed + +- Fixed minor schedule preview issue missing last day ([#2316](https://github.com/grafana/oncall/pull/2316)) ## v1.2.46 (2023-06-22) diff --git a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx index df9ac68b06..7f81899755 100644 --- a/grafana-plugin/src/containers/RotationForm/RotationForm.tsx +++ b/grafana-plugin/src/containers/RotationForm/RotationForm.tsx @@ -370,10 +370,11 @@ const RotationForm = observer((props: RotationFormProps) => { useEffect(() => { if (shift) { setRotationName(getShiftName(shift)); - const rotationStart = getDateTime(shift.rotation_start); - setRotationStart(rotationStart); - setRotationEnd(shift.until ? getDateTime(shift.until) : getDateTime(shift.shift_start).add(1, 'month')); const shiftStart = getDateTime(shift.shift_start); + // use shiftStart as rotationStart for existing shifts + // (original rotationStart defaulted to the shift creation timestamp) + setRotationStart(shiftStart); + setRotationEnd(shift.until ? getDateTime(shift.until) : getDateTime(shift.shift_start).add(1, 'month')); setShiftStart(shiftStart); const shiftEnd = getDateTime(shift.shift_end); setShiftEnd(shiftEnd); diff --git a/grafana-plugin/src/models/schedule/schedule.ts b/grafana-plugin/src/models/schedule/schedule.ts index c0a9ec489c..4071088f9c 100644 --- a/grafana-plugin/src/models/schedule/schedule.ts +++ b/grafana-plugin/src/models/schedule/schedule.ts @@ -252,7 +252,7 @@ export class ScheduleStore extends BaseStore { const dayBefore = startMoment.subtract(1, 'day'); const response = await makeRequest(`/oncall_shifts/preview/`, { - params: { date: getFromString(dayBefore) }, + params: { date: getFromString(dayBefore), days: 8 }, data: { type, schedule: scheduleId, shift_pk: shiftId === 'new' ? undefined : shiftId, ...params }, method: 'POST', });