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)
This commit is contained in:
Matias Bordese 2023-06-23 13:29:36 -03:00 committed by GitHub
parent e308b5298d
commit 5f73af19f0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 10 additions and 4 deletions

View file

@ -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)

View file

@ -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);

View file

@ -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',
});