Skip to content

Commit 607e87c

Browse files
authored
Schedules rotation form tweaks (#3365)
# What this PR does - adds proper boundary constraints on dragging the rotation modal (can't drag outside of parent container anymore) - add scrolling within the users list in the rotation modal ## Which issue(s) this PR fixes Fixes grafana/oncall-private#2299
1 parent 904dca6 commit 607e87c

File tree

4 files changed

+30
-26
lines changed

4 files changed

+30
-26
lines changed

CHANGELOG.md

+5-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## Unreleased
99

10+
### Fixed
11+
12+
- Fixed recurrency limit issue in the Rotation Modal ([#3358](https://github.com/grafana/oncall/pull/3358))
13+
- Added dragging boundary constraints for Rotation Modal and show scroll for the users list ([#3365](https://github.com/grafana/oncall/pull/3365))
14+
1015
## v1.3.58 (2023-11-14)
1116

1217
### Added
@@ -26,7 +31,6 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2631
by excluding dark theme css vars in this case ([#3336](https://github.com/grafana/oncall/pull/3336))
2732
- Fix issue when acknowledge reminder works for deleted organizations @Ferril ([#3345](https://github.com/grafana/oncall/pull/3345))
2833
- Fix generating QR code ([#3347](https://github.com/grafana/oncall/pull/3347))
29-
- Fixed recurrency limit issue in the Rotation Modal ([#3358](https://github.com/grafana/oncall/pull/3358))
3034

3135
## v1.3.57 (2023-11-10)
3236

grafana-plugin/src/components/UserGroups/UserGroups.module.css

+2-21
Original file line numberDiff line numberDiff line change
@@ -24,25 +24,6 @@
2424
margin-top: 12px;
2525
}
2626

27-
/*
28-
.separator::before {
29-
display: block;
30-
content: '';
31-
flex-grow: 1;
32-
border-bottom: var(--border-medium);
33-
height: 0;
34-
margin-right: 5px;
35-
}
36-
37-
.separator::after {
38-
display: block;
39-
content: '';
40-
flex-grow: 1;
41-
border-bottom: var(--border-medium);
42-
height: 0;
43-
margin-left: 5px;
44-
} */
45-
4627
.groups {
4728
width: 100%;
4829
padding: 0;
@@ -51,8 +32,8 @@
5132
display: flex;
5233
flex-direction: column;
5334
gap: 1px;
54-
max-height: calc(100vh - 600px);
55-
overflow: scroll;
35+
max-height: 300px;
36+
overflow: auto;
5637
}
5738

5839
.user {

grafana-plugin/src/containers/RotationForm/RotationForm.module.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.body {
1+
.container {
22
margin: 15px -15px;
33
padding: 15px 0;
44
border-top: var(--border-medium);

grafana-plugin/src/containers/RotationForm/RotationForm.tsx

+22-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import {
1515
import cn from 'classnames/bind';
1616
import dayjs from 'dayjs';
1717
import { observer } from 'mobx-react';
18-
import Draggable from 'react-draggable';
18+
import Draggable, { DraggableData, DraggableEvent } from 'react-draggable';
1919

2020
import Block from 'components/GBlock/Block';
2121
import Modal from 'components/Modal/Modal';
@@ -106,6 +106,10 @@ const RotationForm = observer((props: RotationFormProps) => {
106106

107107
const [errors, setErrors] = useState<{ [key: string]: string[] }>({});
108108

109+
const [bounds, setDraggableBounds] = useState<{ left: number; right: number; top: number; bottom: number }>(
110+
undefined
111+
);
112+
109113
const [rotationName, setRotationName] = useState<string>(`[L${layerPriority}] Rotation`);
110114
const [isOpen, setIsOpen] = useState<boolean>(false);
111115
const [offsetTop, setOffsetTop] = useState<number>(0);
@@ -423,7 +427,8 @@ const RotationForm = observer((props: RotationFormProps) => {
423427
handle=".drag-handler"
424428
defaultClassName={cx('draggable')}
425429
positionOffset={{ x: 0, y: offsetTop }}
426-
bounds={{ top: 0 }}
430+
bounds={bounds || 'body'}
431+
onStart={onDraggableInit}
427432
>
428433
<div {...props}>{children}</div>
429434
</Draggable>
@@ -457,7 +462,7 @@ const RotationForm = observer((props: RotationFormProps) => {
457462
</HorizontalGroup>
458463
</HorizontalGroup>
459464
</div>
460-
<div className={cx('body')}>
465+
<div className={cx('container')}>
461466
<div className={cx('content')}>
462467
<VerticalGroup spacing="none">
463468
{hasUpdatedShift && (
@@ -684,6 +689,20 @@ const RotationForm = observer((props: RotationFormProps) => {
684689
)}
685690
</>
686691
);
692+
693+
function onDraggableInit(_e: DraggableEvent, data: DraggableData) {
694+
if (!data) {
695+
return;
696+
}
697+
698+
const scrollbarView = document.querySelector('.scrollbar-view')?.getBoundingClientRect();
699+
700+
const x = data.node.offsetLeft;
701+
const top = -data.node.offsetTop + (scrollbarView?.top || 100);
702+
const bottom = window.innerHeight - (data.node.offsetTop + data.node.offsetHeight);
703+
704+
setDraggableBounds({ left: -x, right: x, top: top - offsetTop, bottom: bottom - offsetTop });
705+
}
687706
});
688707

689708
interface ShiftPeriodProps {

0 commit comments

Comments
 (0)