Skip to content

Commit 0bd36d2

Browse files
committed
POC merge
1 parent c1d2734 commit 0bd36d2

File tree

2 files changed

+30
-8
lines changed

2 files changed

+30
-8
lines changed

src/components/TestVariationMergeForm.tsx

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react";
2-
import { Grid, Select, MenuItem, Button } from "@material-ui/core";
2+
import { Grid, Select, MenuItem, Button, TextField } from "@material-ui/core";
33
import { testVariationService } from "../services";
44
import { useHistory } from "react-router-dom";
55
import {
@@ -21,12 +21,13 @@ export const TestVariationMergeForm: React.FunctionComponent<IProps> = ({
2121
const history = useHistory();
2222
const buildDispatch = useBuildDispatch();
2323
const { enqueueSnackbar } = useSnackbar();
24-
const [branch, setBranch] = React.useState("");
24+
const [fromBranch, setFromBranch] = React.useState("");
25+
const [toBranch, setToBranch] = React.useState("");
2526

2627
const handleSubmit = (event: React.FormEvent) => {
2728
event.preventDefault();
2829
testVariationService
29-
.merge(projectId, branch)
30+
.merge(projectId, fromBranch, toBranch)
3031
.then((build) => {
3132
enqueueSnackbar(`Merge started in build: ${build.id}`, {
3233
variant: "success",
@@ -50,11 +51,11 @@ export const TestVariationMergeForm: React.FunctionComponent<IProps> = ({
5051
<Grid item>
5152
<Select
5253
displayEmpty
53-
value={branch}
54-
onChange={(event) => setBranch(event.target.value as string)}
54+
value={fromBranch}
55+
onChange={(event) => setFromBranch(event.target.value as string)}
5556
>
5657
<MenuItem value="">
57-
<em>Select branch</em>
58+
<em>From branch</em>
5859
</MenuItem>
5960
{items.map((i) => (
6061
<MenuItem key={i} value={i}>
@@ -63,6 +64,23 @@ export const TestVariationMergeForm: React.FunctionComponent<IProps> = ({
6364
))}
6465
</Select>
6566
</Grid>
67+
<Grid item>
68+
<TextField
69+
id="toBranch"
70+
name="toBranch"
71+
value={toBranch}
72+
label={"To Branch"}
73+
type="text"
74+
variant="outlined"
75+
required
76+
fullWidth
77+
inputProps={{
78+
onChange: (event: any) =>
79+
setToBranch((event.target as HTMLInputElement).value),
80+
"data-testid": "toBranch",
81+
}}
82+
/>
83+
</Grid>
6684
<Grid item>
6785
<Button type="submit" color="primary" variant="contained">
6886
Merge

src/services/testVariation.service.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,18 @@ async function setComment(id: string, comment: string): Promise<TestVariation> {
5656
);
5757
}
5858

59-
async function merge(projectId: String, branchName: String): Promise<Build> {
59+
async function merge(
60+
projectId: String,
61+
fromBranch: String,
62+
toBranch: String
63+
): Promise<Build> {
6064
const requestOptions = {
6165
method: "GET",
6266
headers: authHeader(),
6367
};
6468

6569
return fetch(
66-
`${API_URL}${ENDPOINT_URL}/merge?projectId=${projectId}&branchName=${branchName}`,
70+
`${API_URL}${ENDPOINT_URL}/merge?projectId=${projectId}&fromBranch=${fromBranch}&toBranch=${toBranch}`,
6771
requestOptions
6872
).then(handleResponse);
6973
}

0 commit comments

Comments
 (0)