From 074202e01f21036d43ba29ce441e43c6f46d2707 Mon Sep 17 00:00:00 2001 From: Pavel Strunkin Date: Thu, 16 Jul 2020 21:03:57 +0200 Subject: [PATCH 1/3] approve method added with merge param --- src/components/TestDetailsModal.tsx | 2 +- src/services/testRun.service.ts | 9 +++++---- src/types/testRun.ts | 1 + 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/components/TestDetailsModal.tsx b/src/components/TestDetailsModal.tsx index 45a3129c..dbf5a783 100644 --- a/src/components/TestDetailsModal.tsx +++ b/src/components/TestDetailsModal.tsx @@ -157,7 +157,7 @@ const TestDetailsModal: React.FunctionComponent<{ - + + {testRun.merge && ( + + + + + + )} + + + + + + + )} @@ -213,8 +230,10 @@ const TestDetailsModal: React.FunctionComponent<{ .setComment(testRun.id, comment) .then((testRun) => updateTestRun(testRunDispatch, testRun)), // update in variation - testVariationService - .setComment(testRun.testVariationId, comment), + testVariationService.setComment( + testRun.testVariationId, + comment + ), ]) } /> From 69b7661b030b078c121cbceaeb102a5d37f16e85 Mon Sep 17 00:00:00 2001 From: Pavel Strunkin Date: Thu, 16 Jul 2020 23:56:19 +0200 Subject: [PATCH 3/3] TestVariationMergeForm added --- src/_helpers/route.helpers.ts | 18 +++++--- src/components/TestDetailsModal.tsx | 6 ++- src/components/TestVariationMergeForm.tsx | 53 +++++++++++++++++++++++ src/pages/TestVariationListPage.tsx | 31 ++++++++----- src/services/testVariation.service.ts | 17 +++++++- 5 files changed, 104 insertions(+), 21 deletions(-) create mode 100644 src/components/TestVariationMergeForm.tsx diff --git a/src/_helpers/route.helpers.ts b/src/_helpers/route.helpers.ts index 1d7e65dd..620e45a5 100644 --- a/src/_helpers/route.helpers.ts +++ b/src/_helpers/route.helpers.ts @@ -1,9 +1,15 @@ -import { TestRun, TestVariation } from "../types" -import { routes } from "../constants" +import { TestRun, TestVariation } from "../types"; +import { routes } from "../constants"; -export const buildTestRunUrl = (testVariation: TestVariation, testRun: TestRun) => - `${routes.HOME}${testVariation.projectId}?buildId=${testRun.buildId}&testId=${testRun.id}` +export const buildTestRunUrl = ( + testVariation: TestVariation, + testRun: TestRun +) => + `${routes.HOME}${testVariation.projectId}?buildId=${testRun.buildId}&testId=${testRun.id}`; export const buildTestRunLocation = (testRun: TestRun) => ({ - search: `buildId=${testRun.buildId}&testId=${testRun.id}`, -}) \ No newline at end of file + search: `buildId=${testRun.buildId}&testId=${testRun.id}`, +}); + +export const buildBuildPageUrl = (projectId: string, buildId: string) => + `${routes.HOME}${projectId}?buildId=${buildId}`; diff --git a/src/components/TestDetailsModal.tsx b/src/components/TestDetailsModal.tsx index 2ea2b717..380a0f10 100644 --- a/src/components/TestDetailsModal.tsx +++ b/src/components/TestDetailsModal.tsx @@ -160,7 +160,11 @@ const TestDetailsModal: React.FunctionComponent<{ {testRun.merge && ( - + )} diff --git a/src/components/TestVariationMergeForm.tsx b/src/components/TestVariationMergeForm.tsx new file mode 100644 index 00000000..0033979d --- /dev/null +++ b/src/components/TestVariationMergeForm.tsx @@ -0,0 +1,53 @@ +import React from "react"; +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"; + +interface IProps { + projectId: string; + items: string[]; +} + +export const TestVariationMergeForm: React.FunctionComponent = ({ + projectId, + items, +}) => { + const history = useHistory(); + const [branch, setBranch] = React.useState(""); + + const handleSubmit = (event: React.FormEvent) => { + event.preventDefault(); + testVariationService.merge(projectId, branch).then((build) => { + history.push(buildBuildPageUrl(projectId, build.id)); + }); + }; + + return ( +
+ + + + + + + + +
+ ); +}; diff --git a/src/pages/TestVariationListPage.tsx b/src/pages/TestVariationListPage.tsx index 0edf9516..1f068ce9 100644 --- a/src/pages/TestVariationListPage.tsx +++ b/src/pages/TestVariationListPage.tsx @@ -6,9 +6,10 @@ import { testVariationService } from "../services"; import { Container, Box, Grid, Typography } from "@material-ui/core"; import ProjectSelect from "../components/ProjectSelect"; import Filters from "../components/Filters"; +import { TestVariationMergeForm } from "../components/TestVariationMergeForm"; const TestVariationListPage: React.FunctionComponent = () => { - const { projectId } = useParams(); + const { projectId = "" } = useParams(); const [testVariations, setTestVariations] = React.useState( [] ); @@ -54,17 +55,23 @@ const TestVariationListPage: React.FunctionComponent = () => {
- - - + t.branchName)) + )} + /> + + + diff --git a/src/services/testVariation.service.ts b/src/services/testVariation.service.ts index 5cd179ab..1b66d167 100644 --- a/src/services/testVariation.service.ts +++ b/src/services/testVariation.service.ts @@ -1,4 +1,4 @@ -import { TestVariation } from "../types"; +import { TestVariation, Build } from "../types"; import { handleResponse, authHeader } from "../_helpers/service.helpers"; import { API_URL } from "../_config/api.config"; import { IgnoreArea } from "../types/ignoreArea"; @@ -10,6 +10,7 @@ export const testVariationService = { getDetails, setIgnoreAreas, setComment, + merge, }; function getList(projectId: String): Promise { @@ -30,7 +31,7 @@ function getDetails(id: String): Promise { headers: authHeader(), }; - return fetch(`${API_URL}${ENDPOINT_URL}/${id}`, requestOptions).then( + return fetch(`${API_URL}${ENDPOINT_URL}/details/${id}`, requestOptions).then( handleResponse ); } @@ -62,3 +63,15 @@ function setComment(id: string, comment: string): Promise { handleResponse ); } + +function merge(projectId: String, branchName: String): Promise { + const requestOptions = { + method: "GET", + headers: authHeader(), + }; + + return fetch( + `${API_URL}${ENDPOINT_URL}/merge?projectId=${projectId}&branchName=${branchName}`, + requestOptions + ).then(handleResponse); +} \ No newline at end of file