Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/components/ProjectForm/ProjectForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,26 @@ export const ProjectForm: React.FunctionComponent = () => {
});
}}
/>
<TextValidator
name="maxBranchLifetime"
validators={["minNumber:1"]}
errorMessages={["Enter greater than 1"]}
InputProps={{ inputProps: { min: 1, step: 1 } }}
margin="dense"
id="maxBranchLifetime"
label="Max branch lifetime (days)"
type="number"
fullWidth
required
value={project.maxBranchLifetime}
onChange={(event) => {
const value = (event.target as HTMLInputElement).value;
setProjectEditState(projectDispatch, {
...project,
maxBranchLifetime: parseInt(value),
});
}}
/>
<FormControlLabel
label="Auto approve feature"
control={
Expand Down
62 changes: 37 additions & 25 deletions src/components/TestDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@ import {
import { ToggleButton } from "@material-ui/lab";
import { useHotkeys } from "react-hotkeys-hook";
import { TestRun } from "../types";
import {
testRunService,
staticService,
} from "../services";
import { testRunService, staticService } from "../services";
import { TestStatus } from "../types/testStatus";
import { useHistory, Prompt } from "react-router-dom";
import { IgnoreArea, UpdateIgnoreAreaDto } from "../types/ignoreArea";
Expand Down Expand Up @@ -173,9 +170,9 @@ const TestDetailsModal: React.FunctionComponent<{
const fitStageToScreen = () => {
const scale = image
? Math.min(
stageWidth < image.width ? stageWidth / image.width : 1,
stageHeigth < image.height ? stageHeigth / image.height : 1
)
stageWidth < image.width ? stageWidth / image.width : 1,
stageHeigth < image.height ? stageHeigth / image.height : 1
)
: 1;
setStageScale(scale);
resetPositioin();
Expand All @@ -190,23 +187,36 @@ const TestDetailsModal: React.FunctionComponent<{
let newIgnoreArea = ignoreAreas.find((area) => selectedRectId! === area.id);
if (newIgnoreArea) {
setProcessing(true);
testRunService.getList(testRun.buildId).then(
(testRuns: TestRun[]) => {
testRunService
.getList(testRun.buildId)
.then((testRuns: TestRun[]) => {
let allIds = testRuns.map((item) => item.id);
let data: UpdateIgnoreAreaDto = { ids: allIds, ignoreAreas: [newIgnoreArea!] };
let data: UpdateIgnoreAreaDto = {
ids: allIds,
ignoreAreas: [newIgnoreArea!],
};
testRunService.addIgnoreAreas(data).then(() => {
setProcessing(false);
setSelectedRectId(undefined);
enqueueSnackbar("Ignore areas are updated in all images in this build.", {
variant: "success",
});
enqueueSnackbar(
"Ignore areas are updated in all images in this build.",
{
variant: "success",
}
);
});
})
.catch((error) => {
enqueueSnackbar("There was an error : " + error, {
variant: "error",
});
}).catch((error) => {
enqueueSnackbar("There was an error : " + error, { variant: "error" });
setProcessing(false);
});
} else {
enqueueSnackbar("There was an error determining which ignore area to apply.", { variant: "error" });
enqueueSnackbar(
"There was an error determining which ignore area to apply.",
{ variant: "error" }
);
}
};

Expand Down Expand Up @@ -265,10 +275,10 @@ const TestDetailsModal: React.FunctionComponent<{
)}
{(testRun.status === TestStatus.unresolved ||
testRun.status === TestStatus.new) && (
<Grid item>
<ApproveRejectButtons testRun={testRun} />
</Grid>
)}
<Grid item>
<ApproveRejectButtons testRun={testRun} />
</Grid>
)}
<Grid item>
<IconButton color="inherit" onClick={handleClose}>
<Close />
Expand All @@ -277,7 +287,7 @@ const TestDetailsModal: React.FunctionComponent<{
</Grid>
</Toolbar>
</AppBar>
{(processing) && <LinearProgress />}
{processing && <LinearProgress />}
<Box m={1}>
<Grid container alignItems="center">
<Grid item xs={12}>
Expand Down Expand Up @@ -349,13 +359,14 @@ const TestDetailsModal: React.FunctionComponent<{
</IconButton>
</Grid>
</Tooltip>
<Tooltip title="Apply selected ignore area to all images in this build." aria-label="apply ignore area">
<Tooltip
title="Apply selected ignore area to all images in this build."
aria-label="apply ignore area"
>
<Grid item>
<IconButton
disabled={!selectedRectId || ignoreAreas.length === 0}
onClick={() =>
applyIgnoreArea()
}
onClick={() => applyIgnoreArea()}
>
<Collections />
</IconButton>
Expand All @@ -374,6 +385,7 @@ const TestDetailsModal: React.FunctionComponent<{
<Grid item>
<Button
color="primary"
disabled={!testRun.testVariationId}
onClick={() => {
history.push(
`${routes.VARIATION_DETAILS_PAGE}/${testRun.testVariationId}`
Expand Down
1 change: 1 addition & 0 deletions src/constants/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,5 @@ export const DEFAULT_PROJECT_EDIT_STATE: ProjectDto = {
imageComparison: ImageComparison.pixelmatch,
imageComparisonConfig: PIXELMATCH_DEFAULT_CONFIG,
maxBuildAllowed: 100,
maxBranchLifetime: 30,
};
1 change: 1 addition & 0 deletions src/types/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export interface Project {
imageComparison: ImageComparison;
imageComparisonConfig: string;
maxBuildAllowed: number;
maxBranchLifetime: number;
}

export type ProjectDto = Omit<Project, "updatedAt" | "createdAt" | "builds">;