Skip to content

Commit 0cb3964

Browse files
authored
275 tv clean (#216)
* Clean up old test variations Visual-Regression-Tracker/Visual-Regression-Tracker#275 * Clean up old test variations Visual-Regression-Tracker/Visual-Regression-Tracker#275
1 parent 61caa93 commit 0cb3964

File tree

1 file changed

+37
-25
lines changed

1 file changed

+37
-25
lines changed

src/components/TestDetailsModal.tsx

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@ import {
1717
import { ToggleButton } from "@material-ui/lab";
1818
import { useHotkeys } from "react-hotkeys-hook";
1919
import { TestRun } from "../types";
20-
import {
21-
testRunService,
22-
staticService,
23-
} from "../services";
20+
import { testRunService, staticService } from "../services";
2421
import { TestStatus } from "../types/testStatus";
2522
import { useHistory, Prompt } from "react-router-dom";
2623
import { IgnoreArea, UpdateIgnoreAreaDto } from "../types/ignoreArea";
@@ -173,9 +170,9 @@ const TestDetailsModal: React.FunctionComponent<{
173170
const fitStageToScreen = () => {
174171
const scale = image
175172
? Math.min(
176-
stageWidth < image.width ? stageWidth / image.width : 1,
177-
stageHeigth < image.height ? stageHeigth / image.height : 1
178-
)
173+
stageWidth < image.width ? stageWidth / image.width : 1,
174+
stageHeigth < image.height ? stageHeigth / image.height : 1
175+
)
179176
: 1;
180177
setStageScale(scale);
181178
resetPositioin();
@@ -190,23 +187,36 @@ const TestDetailsModal: React.FunctionComponent<{
190187
let newIgnoreArea = ignoreAreas.find((area) => selectedRectId! === area.id);
191188
if (newIgnoreArea) {
192189
setProcessing(true);
193-
testRunService.getList(testRun.buildId).then(
194-
(testRuns: TestRun[]) => {
190+
testRunService
191+
.getList(testRun.buildId)
192+
.then((testRuns: TestRun[]) => {
195193
let allIds = testRuns.map((item) => item.id);
196-
let data: UpdateIgnoreAreaDto = { ids: allIds, ignoreAreas: [newIgnoreArea!] };
194+
let data: UpdateIgnoreAreaDto = {
195+
ids: allIds,
196+
ignoreAreas: [newIgnoreArea!],
197+
};
197198
testRunService.addIgnoreAreas(data).then(() => {
198199
setProcessing(false);
199200
setSelectedRectId(undefined);
200-
enqueueSnackbar("Ignore areas are updated in all images in this build.", {
201-
variant: "success",
202-
});
201+
enqueueSnackbar(
202+
"Ignore areas are updated in all images in this build.",
203+
{
204+
variant: "success",
205+
}
206+
);
207+
});
208+
})
209+
.catch((error) => {
210+
enqueueSnackbar("There was an error : " + error, {
211+
variant: "error",
203212
});
204-
}).catch((error) => {
205-
enqueueSnackbar("There was an error : " + error, { variant: "error" });
206213
setProcessing(false);
207214
});
208215
} else {
209-
enqueueSnackbar("There was an error determining which ignore area to apply.", { variant: "error" });
216+
enqueueSnackbar(
217+
"There was an error determining which ignore area to apply.",
218+
{ variant: "error" }
219+
);
210220
}
211221
};
212222

@@ -265,10 +275,10 @@ const TestDetailsModal: React.FunctionComponent<{
265275
)}
266276
{(testRun.status === TestStatus.unresolved ||
267277
testRun.status === TestStatus.new) && (
268-
<Grid item>
269-
<ApproveRejectButtons testRun={testRun} />
270-
</Grid>
271-
)}
278+
<Grid item>
279+
<ApproveRejectButtons testRun={testRun} />
280+
</Grid>
281+
)}
272282
<Grid item>
273283
<IconButton color="inherit" onClick={handleClose}>
274284
<Close />
@@ -277,7 +287,7 @@ const TestDetailsModal: React.FunctionComponent<{
277287
</Grid>
278288
</Toolbar>
279289
</AppBar>
280-
{(processing) && <LinearProgress />}
290+
{processing && <LinearProgress />}
281291
<Box m={1}>
282292
<Grid container alignItems="center">
283293
<Grid item xs={12}>
@@ -349,13 +359,14 @@ const TestDetailsModal: React.FunctionComponent<{
349359
</IconButton>
350360
</Grid>
351361
</Tooltip>
352-
<Tooltip title="Apply selected ignore area to all images in this build." aria-label="apply ignore area">
362+
<Tooltip
363+
title="Apply selected ignore area to all images in this build."
364+
aria-label="apply ignore area"
365+
>
353366
<Grid item>
354367
<IconButton
355368
disabled={!selectedRectId || ignoreAreas.length === 0}
356-
onClick={() =>
357-
applyIgnoreArea()
358-
}
369+
onClick={() => applyIgnoreArea()}
359370
>
360371
<Collections />
361372
</IconButton>
@@ -374,6 +385,7 @@ const TestDetailsModal: React.FunctionComponent<{
374385
<Grid item>
375386
<Button
376387
color="primary"
388+
disabled={!testRun.testVariationId}
377389
onClick={() => {
378390
history.push(
379391
`${routes.VARIATION_DETAILS_PAGE}/${testRun.testVariationId}`

0 commit comments

Comments
 (0)