Skip to content

Commit 960414a

Browse files
authored
Fix for issue 317 (#240)
* Fix for issue 317 Fixes Visual-Regression-Tracker/Visual-Regression-Tracker#317 * Fixed review comments.
1 parent b334196 commit 960414a

File tree

1 file changed

+33
-9
lines changed

1 file changed

+33
-9
lines changed

src/components/TestDetailsDialog/TestDetailsModal.tsx

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ import { ScaleActionsSpeedDial } from "../ZoomSpeedDial";
4242
import { ApproveRejectButtons } from "../ApproveRejectButtons";
4343
import { head } from "lodash";
4444
import { invertIgnoreArea } from "../../_helpers/ignoreArea.helper";
45+
import { BaseModal } from "../BaseModal";
4546

4647
const defaultStagePos = {
4748
x: 0,
@@ -84,6 +85,11 @@ const TestDetailsModal: React.FunctionComponent<{
8485
const [isDiffShown, setIsDiffShown] = useState(!!testRun.diffName);
8586
const [selectedRectId, setSelectedRectId] = React.useState<string>();
8687
const [ignoreAreas, setIgnoreAreas] = React.useState<IgnoreArea[]>([]);
88+
const [applyIgnoreDialogOpen, setApplyIgnoreDialogOpen] = React.useState(false);
89+
90+
const toggleApplyIgnoreDialogOpen = () => {
91+
setApplyIgnoreDialogOpen(!applyIgnoreDialogOpen);
92+
};
8793

8894
const [image, imageStatus] = useImage(
8995
staticService.getImage(testRun.imageName)
@@ -95,6 +101,8 @@ const TestDetailsModal: React.FunctionComponent<{
95101
staticService.getImage(testRun.diffName)
96102
);
97103

104+
const applyIgnoreAreaText = 'Apply selected ignore area to all images in this build.';
105+
98106
React.useEffect(() => {
99107
fitStageToScreen();
100108
// eslint-disable-next-line
@@ -187,9 +195,9 @@ const TestDetailsModal: React.FunctionComponent<{
187195
const fitStageToScreen = () => {
188196
const scale = image
189197
? Math.min(
190-
stageWidth < image.width ? stageWidth / image.width : 1,
191-
stageHeigth < image.height ? stageHeigth / image.height : 1
192-
)
198+
stageWidth < image.width ? stageWidth / image.width : 1,
199+
stageHeigth < image.height ? stageHeigth / image.height : 1
200+
)
193201
: 1;
194202
setStageScale(scale);
195203
resetPositioin();
@@ -266,10 +274,10 @@ const TestDetailsModal: React.FunctionComponent<{
266274
)}
267275
{(testRun.status === TestStatus.unresolved ||
268276
testRun.status === TestStatus.new) && (
269-
<Grid item>
270-
<ApproveRejectButtons testRun={testRun} />
271-
</Grid>
272-
)}
277+
<Grid item>
278+
<ApproveRejectButtons testRun={testRun} />
279+
</Grid>
280+
)}
273281
<Grid item>
274282
<IconButton color="inherit" onClick={handleClose}>
275283
<Close />
@@ -353,13 +361,13 @@ const TestDetailsModal: React.FunctionComponent<{
353361
</Grid>
354362
</Tooltip>
355363
<Tooltip
356-
title="Apply selected ignore area to all images in this build."
364+
title={applyIgnoreAreaText}
357365
aria-label="apply ignore area"
358366
>
359367
<Grid item>
360368
<IconButton
361369
disabled={!selectedRectId || ignoreAreas.length === 0}
362-
onClick={() => applyIgnoreArea()}
370+
onClick={() => toggleApplyIgnoreDialogOpen()}
363371
>
364372
<Collections />
365373
</IconButton>
@@ -481,6 +489,22 @@ const TestDetailsModal: React.FunctionComponent<{
481489
onOriginalSizeClick={setOriginalSize}
482490
onFitIntoScreenClick={fitStageToScreen}
483491
/>
492+
<BaseModal
493+
open={applyIgnoreDialogOpen}
494+
title={applyIgnoreAreaText}
495+
submitButtonText={'Yes'}
496+
onCancel={toggleApplyIgnoreDialogOpen}
497+
content={
498+
<Typography>
499+
{`All images in the current build will be re-compared with new ignore area taken into account. Are you sure?`}
500+
</Typography>
501+
}
502+
onSubmit={() => {
503+
toggleApplyIgnoreDialogOpen();
504+
applyIgnoreArea();
505+
}
506+
}
507+
/>
484508
</React.Fragment>
485509
);
486510
};

0 commit comments

Comments
 (0)