Skip to content

Commit

Permalink
Minor updates to schedule rotation form and preview (#2316)
Browse files Browse the repository at this point in the history
- 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)
  • Loading branch information
matiasb authored Jun 23, 2023
1 parent e308b52 commit 5f73af1
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
7 changes: 4 additions & 3 deletions grafana-plugin/src/containers/RotationForm/RotationForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion grafana-plugin/src/models/schedule/schedule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
});
Expand Down

0 comments on commit 5f73af1

Please sign in to comment.