Skip to content

Commit 2f282bd

Browse files
committed
Disable zoom in/zoom out/reset buttons
1 parent 210c5e8 commit 2f282bd

File tree

3 files changed

+50
-7
lines changed

3 files changed

+50
-7
lines changed

src/main/frontend/pipeline-console-view/pipeline-console/main/components/stages.scss

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,22 +23,23 @@
2323
}
2424

2525
&__heading {
26+
padding: 0 0.55rem;
2627
bottom: unset !important;
2728
right: unset !important;
29+
line-height: 2rem;
2830
font-weight: var(--font-bold-weight);
2931
font-size: var(--font-size-sm);
3032
}
3133
}
3234

3335
.test-floaty-material {
3436
position: absolute;
35-
inset: 0.4rem 0.3rem;
37+
inset: 0.1rem;
3638
display: flex;
3739
z-index: 1;
3840
backdrop-filter: blur(10px);
3941
background: red;
4042
border-radius: 0.45rem;
41-
padding: 0.2rem 0.4375rem;
4243
align-items: center;
4344
color: var(--text-color-secondary);
4445
background: color-mix(in srgb, var(--card-background) 80%, transparent);

src/main/frontend/pipeline-graph-view/app.scss

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,40 @@
4747

4848
.pgw-fullscreen-controls,
4949
.pgw-zoom-controls {
50-
padding: 0.2rem !important;
51-
5250
.jenkins-button {
51+
--button-background: transparent;
52+
--button-background--hover: transparent;
53+
--button-background--active: transparent;
54+
--button-box-shadow--focus: transparent;
55+
5356
padding: 0;
54-
width: 1.75rem;
55-
min-height: 1.75rem;
57+
width: 2rem;
58+
min-height: 2rem;
5659
border-radius: 0.35rem;
5760

61+
&::before {
62+
border: none;
63+
}
64+
5865
svg {
5966
width: 1rem;
6067
height: 1rem;
6168
color: var(--text-color-secondary);
6269
}
70+
71+
&:not(:disabled) {
72+
&:hover {
73+
svg {
74+
opacity: 0.75;
75+
}
76+
}
77+
78+
&:active {
79+
svg {
80+
opacity: 0.5;
81+
}
82+
}
83+
}
6384
}
6485
}
6586

src/main/frontend/pipeline-graph-view/pipeline-graph/main/PipelineGraph.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
TransformWrapper,
2222
TransformComponent,
2323
useControls,
24+
useTransformEffect,
2425
} from "react-zoom-pan-pinch";
2526
import Tooltip from "../../../common/components/tooltip.tsx";
2627

@@ -114,7 +115,7 @@ export function PipelineGraph(props: Props) {
114115
};
115116

116117
return (
117-
<TransformWrapper minScale={0.75}>
118+
<TransformWrapper minScale={0.75} maxScale={3}>
118119
<ZoomControls />
119120

120121
<TransformComponent wrapperStyle={{ width: "100%", height: "100%" }}>
@@ -178,13 +179,31 @@ export function PipelineGraph(props: Props) {
178179

179180
function ZoomControls() {
180181
const { zoomIn, zoomOut, resetTransform } = useControls();
182+
const [disabledButtons, setDisabledButtons] = useState({
183+
zoomIn: false,
184+
zoomOut: false,
185+
reset: true,
186+
});
187+
188+
useTransformEffect(({ state, instance }) => {
189+
const cantZoomIn = state.scale >= instance.props.maxScale!;
190+
const cantZoomOut = state.scale <= instance.props.minScale!;
191+
const cantReset = state.scale === 1;
192+
193+
setDisabledButtons({
194+
zoomIn: cantZoomIn,
195+
zoomOut: cantZoomOut,
196+
reset: cantReset,
197+
});
198+
});
181199

182200
return (
183201
<div className="test-floaty-material pgw-zoom-controls">
184202
<Tooltip content={"Zoom in"}>
185203
<button
186204
className={"jenkins-button jenkins-button--tertiary"}
187205
onClick={() => zoomIn()}
206+
disabled={disabledButtons.zoomIn}
188207
>
189208
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
190209
<path
@@ -202,6 +221,7 @@ function ZoomControls() {
202221
<button
203222
className={"jenkins-button jenkins-button--tertiary"}
204223
onClick={() => zoomOut()}
224+
disabled={disabledButtons.zoomOut}
205225
>
206226
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
207227
<path
@@ -219,6 +239,7 @@ function ZoomControls() {
219239
<button
220240
className={"jenkins-button jenkins-button--tertiary"}
221241
onClick={() => resetTransform()}
242+
disabled={disabledButtons.reset}
222243
>
223244
<svg className="ionicon" viewBox="0 0 512 512">
224245
<path

0 commit comments

Comments
 (0)