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
11 changes: 10 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"@testing-library/user-event": "^7.2.1",
"konva": "^4.2.2",
"material-ui-popup-state": "^1.6.1",
"notistack": "^0.9.17",
"qs": "^6.9.4",
"react": "^16.13.1",
"react-debounce-input": "^3.2.2",
Expand Down
31 changes: 17 additions & 14 deletions src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import React from "react";
import { SnackbarProvider } from 'notistack';
import "./App.css";
import Header from "./components/Header";
import {
Expand All @@ -12,20 +13,22 @@ import { SocketProvider } from "./contexts/socket.context";

function App() {
return (
<div className="App">
<AuthProvider>
<ProjectProvider>
<BuildProvider>
<TestRunProvider>
<SocketProvider>
<Header />
<Router />
</SocketProvider>
</TestRunProvider>
</BuildProvider>
</ProjectProvider>
</AuthProvider>
</div>
<SnackbarProvider maxSnack={3}>
<div className="App">
<AuthProvider>
<ProjectProvider>
<BuildProvider>
<TestRunProvider>
<SocketProvider>
<Header />
<Router />
</SocketProvider>
</TestRunProvider>
</BuildProvider>
</ProjectProvider>
</AuthProvider>
</div>
</SnackbarProvider>
);
}

Expand Down
14 changes: 13 additions & 1 deletion src/components/BuildList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
import { BuildStatusChip } from "./BuildStatusChip";
import { SkeletonList } from "./SkeletonList";
import { formatDateTime } from "../_helpers/format.helper";
import { useSnackbar } from "notistack";

const useStyles = makeStyles((theme: Theme) =>
createStyles({
Expand All @@ -42,6 +43,7 @@ const BuildList: FunctionComponent = () => {
const history = useHistory();
const { buildList, selectedBuildId, loading } = useBuildState();
const buildDispatch = useBuildDispatch();
const { enqueueSnackbar } = useSnackbar();

return (
<List>
Expand Down Expand Up @@ -98,7 +100,17 @@ const BuildList: FunctionComponent = () => {
>
<IconButton
onClick={() => {
deleteBuild(buildDispatch, build.id);
deleteBuild(buildDispatch, build.id)
.then((b) =>
enqueueSnackbar(`${b.id} removed`, {
variant: "success",
})
)
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
);
}}
>
<Delete />
Expand Down
8 changes: 7 additions & 1 deletion src/components/LoginForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,21 @@ import {
} from "@material-ui/core";
import { useAuthDispatch, login } from "../contexts";
import { routes } from "../constants";
import { useSnackbar } from "notistack";

const LoginForm = () => {
const { enqueueSnackbar } = useSnackbar();
const [email, setEmail] = useState("");
const [password, setPassword] = useState("");
const dispatch = useAuthDispatch();

const handleSubmit = (event: FormEvent) => {
event.preventDefault();
login(dispatch, email, password);
login(dispatch, email, password).catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
);
};

return (
Expand Down
9 changes: 8 additions & 1 deletion src/components/RegisterForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import {
} from "@material-ui/core";
import { useAuthDispatch, login } from "../contexts";
import { usersService } from "../services";
import { useSnackbar } from "notistack";

const RegisterForm = () => {
const { enqueueSnackbar } = useSnackbar();
const [email, setEmail] = useState("");
const [firstName, setFirstName] = useState("");
const [lastName, setLastName] = useState("");
Expand All @@ -21,7 +23,12 @@ const RegisterForm = () => {
event.preventDefault();
usersService
.register(firstName, lastName, email, password)
.then(() => login(dispatch, email, password));
.then(() => login(dispatch, email, password))
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
);
};

return (
Expand Down
80 changes: 64 additions & 16 deletions src/components/TestDetailsModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ import { routes } from "../constants";
import { useTestRunDispatch, updateTestRun, selectTestRun } from "../contexts";
import { DrawArea } from "./DrawArea";
import { CommentsPopper } from "./CommentsPopper";
import { useSnackbar } from "notistack";

const useStyles = makeStyles((theme) => ({
imageContainer: {
Expand All @@ -57,6 +58,7 @@ const TestDetailsModal: React.FunctionComponent<{
}> = ({ testRun }) => {
const classes = useStyles();
const history = useHistory();
const { enqueueSnackbar } = useSnackbar();
const testRunDispatch = useTestRunDispatch();

const stageWidth = (window.innerWidth / 2) * 0.9;
Expand Down Expand Up @@ -177,6 +179,16 @@ const TestDetailsModal: React.FunctionComponent<{
.then((testRun) => {
updateTestRun(testRunDispatch, testRun);
})
.then(() =>
enqueueSnackbar("Approved", {
variant: "success",
})
)
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
)
}
>
Approve
Expand All @@ -186,9 +198,21 @@ const TestDetailsModal: React.FunctionComponent<{
<Button
color="secondary"
onClick={() =>
testRunService.reject(testRun.id).then((testRun) => {
updateTestRun(testRunDispatch, testRun);
})
testRunService
.reject(testRun.id)
.then((testRun) => {
updateTestRun(testRunDispatch, testRun);
})
.then(() =>
enqueueSnackbar("Rejected", {
variant: "success",
})
)
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
)
}
>
Reject
Expand Down Expand Up @@ -239,6 +263,16 @@ const TestDetailsModal: React.FunctionComponent<{
comment
),
])
.then(() =>
enqueueSnackbar("Comment updated", {
variant: "success",
})
)
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
)
}
/>
</Grid>
Expand Down Expand Up @@ -274,25 +308,39 @@ const TestDetailsModal: React.FunctionComponent<{
<Grid item>
<IconButton
disabled={isIgnoreAreasSaved()}
onClick={() => {
// update in test run
testRunService
.setIgnoreAreas(testRun.id, ignoreAreas)
.then(() =>
onClick={() =>
Promise.all([
// update in test run
testRunService.setIgnoreAreas(testRun.id, ignoreAreas),
// update in variation
testVariationService.setIgnoreAreas(
testRun.testVariationId,
ignoreAreas
),
])
.then(() => {
enqueueSnackbar("Ignore areas are updated", {
variant: "success",
});

// recalculate diff
testRunService
.recalculateDiff(testRun.id)
.then((testRun) =>
updateTestRun(testRunDispatch, testRun)
)
);

// update in variation
testVariationService.setIgnoreAreas(
testRun.testVariationId,
ignoreAreas
);
}}
.then(() =>
enqueueSnackbar("Diff recalculated", {
variant: "success",
})
);
})
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
)
}
>
<Save />
</IconButton>
Expand Down
14 changes: 13 additions & 1 deletion src/components/TestRunList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,12 @@ import {
} from "../contexts";
import { Skeleton } from "@material-ui/lab";
import { SkeletonList } from "./SkeletonList";
import { useSnackbar } from "notistack";

const TestRunList: React.FunctionComponent<{
items: TestRun[];
}> = ({ items }) => {
const { enqueueSnackbar } = useSnackbar();
const { selectedTestRunId, loading } = useTestRunState();
const testRunDispatch = useTestRunDispatch();
const history = useHistory();
Expand Down Expand Up @@ -134,7 +136,17 @@ const TestRunList: React.FunctionComponent<{
</MenuItem>
<MenuItem
onClick={() => {
deleteTestRun(testRunDispatch, selectedTestRun.id);
deleteTestRun(testRunDispatch, selectedTestRun.id)
.then((testRun) => {
enqueueSnackbar(`Deleted`, {
variant: "success",
});
})
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
);
handleClose();
}}
>
Expand Down
18 changes: 15 additions & 3 deletions src/components/TestVariationMergeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { Grid, Select, MenuItem, Button } from "@material-ui/core";
import { testVariationService } from "../services";
import { useHistory } from "react-router-dom";
import { buildBuildPageUrl } from "../_helpers/route.helpers";
import { useSnackbar } from "notistack";

interface IProps {
projectId: string;
Expand All @@ -14,13 +15,24 @@ export const TestVariationMergeForm: React.FunctionComponent<IProps> = ({
items,
}) => {
const history = useHistory();
const { enqueueSnackbar } = useSnackbar();
const [branch, setBranch] = React.useState("");

const handleSubmit = (event: React.FormEvent) => {
event.preventDefault();
testVariationService.merge(projectId, branch).then((build) => {
history.push(buildBuildPageUrl(projectId, build.id));
});
testVariationService
.merge(projectId, branch)
.then((build) => {
enqueueSnackbar(`Merge started in build: ${build.id}`, {
variant: "success",
});
history.push(buildBuildPageUrl(projectId, build.id));
})
.catch((err) =>
enqueueSnackbar(err, {
variant: "error",
})
);
};

return (
Expand Down
Loading