Skip to content

Commit 40daae7

Browse files
authored
Issue 211 : Remove toggle when no baseline or no diff. (#151)
* Issue 211 : Remove toggle when no baseline or no diff.
1 parent ff98224 commit 40daae7

File tree

2 files changed

+39
-36
lines changed

2 files changed

+39
-36
lines changed

src/components/ImageDetails.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const ImageDetails: React.FunctionComponent<IProps> = ({
3737
<Grid item>
3838
<Tooltip
3939
title={
40-
"Contains noneditable ignore areas applyed during image upload."
40+
"Contains noneditable ignore areas applied during image upload."
4141
}
4242
>
4343
<IconButton>

src/components/TestDetailsModal.tsx

Lines changed: 38 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,9 @@ const TestDetailsModal: React.FunctionComponent<{
116116
const fitStageToScreen = () => {
117117
const scale = image
118118
? Math.min(
119-
stageWidth < image.width ? stageWidth / image.width : 1,
120-
stageHeigth < image.height ? stageHeigth / image.height : 1
121-
)
119+
stageWidth < image.width ? stageWidth / image.width : 1,
120+
stageHeigth < image.height ? stageHeigth / image.height : 1
121+
)
122122
: 1;
123123
setStageScale(scale);
124124
resetPositioin();
@@ -151,8 +151,9 @@ const TestDetailsModal: React.FunctionComponent<{
151151
[image, baselineImage, testRun.baselineName, testRun.imageName]
152152
);
153153

154-
useHotkeys("d", () => setIsDiffShown((isDiffShown) => !isDiffShown));
154+
useHotkeys("d", () => shouldDiffHotKeyBeActive && setIsDiffShown((isDiffShown) => !isDiffShown));
155155
useHotkeys("ESC", () => handleClose());
156+
const shouldDiffHotKeyBeActive = !!testRun.diffName;
156157

157158
return (
158159
<React.Fragment>
@@ -166,21 +167,23 @@ const TestDetailsModal: React.FunctionComponent<{
166167
<Grid item>
167168
<Typography variant="h6">{testRun.name}</Typography>
168169
</Grid>
169-
<Grid item>
170-
<Tooltip title={"Hotkey: D"}>
171-
<Switch
172-
checked={isDiffShown}
173-
onChange={() => setIsDiffShown(!isDiffShown)}
174-
name="Toggle diff"
175-
/>
176-
</Tooltip>
177-
</Grid>
178-
{(testRun.status === TestStatus.unresolved ||
179-
testRun.status === TestStatus.new) && (
170+
{(shouldDiffHotKeyBeActive) && (
180171
<Grid item>
181-
<ApproveRejectButtons testRun={testRun} />
172+
<Tooltip title={"Hotkey: D"}>
173+
<Switch
174+
checked={isDiffShown}
175+
onChange={() => setIsDiffShown(!isDiffShown)}
176+
name="Toggle diff"
177+
/>
178+
</Tooltip>
182179
</Grid>
183180
)}
181+
{(testRun.status === TestStatus.unresolved ||
182+
testRun.status === TestStatus.new) && (
183+
<Grid item>
184+
<ApproveRejectButtons testRun={testRun} />
185+
</Grid>
186+
)}
184187
<Grid item>
185188
<IconButton color="inherit" onClick={handleClose}>
186189
<Close />
@@ -335,7 +338,7 @@ const TestDetailsModal: React.FunctionComponent<{
335338
/>
336339
</Grid>
337340
<Grid item xs={6} className={classes.drawAreaItem}>
338-
{isDiffShown ? (
341+
{(isDiffShown) ? (
339342
<DrawArea
340343
type="Diff"
341344
imageName={testRun.diffName}
@@ -354,24 +357,24 @@ const TestDetailsModal: React.FunctionComponent<{
354357
drawModeState={[isDrawMode, setIsDrawMode]}
355358
/>
356359
) : (
357-
<DrawArea
358-
type="Image"
359-
imageName={testRun.imageName}
360-
branchName={testRun.branchName}
361-
imageState={[image, imageStatus]}
362-
ignoreAreas={ignoreAreas}
363-
tempIgnoreAreas={JSON.parse(testRun.tempIgnoreAreas)}
364-
setIgnoreAreas={setIgnoreAreas}
365-
selectedRectId={selectedRectId}
366-
setSelectedRectId={setSelectedRectId}
367-
onStageClick={removeSelection}
368-
stageScaleState={[stageScale, setStageScale]}
369-
stagePosState={[stagePos, setStagePos]}
370-
stageInitPosState={[stageInitPos, setStageInitPos]}
371-
stageOffsetState={[stageOffset, setStageOffset]}
372-
drawModeState={[isDrawMode, setIsDrawMode]}
373-
/>
374-
)}
360+
<DrawArea
361+
type="Image"
362+
imageName={testRun.imageName}
363+
branchName={testRun.branchName}
364+
imageState={[image, imageStatus]}
365+
ignoreAreas={ignoreAreas}
366+
tempIgnoreAreas={JSON.parse(testRun.tempIgnoreAreas)}
367+
setIgnoreAreas={setIgnoreAreas}
368+
selectedRectId={selectedRectId}
369+
setSelectedRectId={setSelectedRectId}
370+
onStageClick={removeSelection}
371+
stageScaleState={[stageScale, setStageScale]}
372+
stagePosState={[stagePos, setStagePos]}
373+
stageInitPosState={[stageInitPos, setStageInitPos]}
374+
stageOffsetState={[stageOffset, setStageOffset]}
375+
drawModeState={[isDrawMode, setIsDrawMode]}
376+
/>
377+
)}
375378
</Grid>
376379
</Grid>
377380
</Box>

0 commit comments

Comments
 (0)