From aa44bac6829824e3c5561df6cb6bb4cb5a5667d3 Mon Sep 17 00:00:00 2001 From: itaigilo Date: Sun, 29 Sep 2024 08:17:48 +0300 Subject: [PATCH] Integrate Merge PR API (#8232) * Update src-dest UI in Pulls list * Show closed/merged timestamp in the Pulls list * Show merged commit link in merged PR details * Cleanup * Handle empty diffs * Handle deleted branch errors * Disable button when branch not found * Update field name * Fix PR comments * Integrate Merge PR API * Remove log * Update error message --- webui/package-lock.json | 7 ++++--- webui/package.json | 1 - webui/src/lib/api/index.js | 20 +++++++++++++++++++ .../repository/pulls/createPull.jsx | 2 +- .../repository/pulls/pullDetails.jsx | 13 +++--------- 5 files changed, 28 insertions(+), 15 deletions(-) diff --git a/webui/package-lock.json b/webui/package-lock.json index 45256b8fcae..dc71cdb1a5d 100644 --- a/webui/package-lock.json +++ b/webui/package-lock.json @@ -17,7 +17,6 @@ "bootstrap": "^5.3.2", "csstype": "^3.1.3", "dayjs": "^1.11.10", - "exponential-backoff": "^3.1.1", "lodash": "^4.17.21", "p-map": "^7.0.0", "prismjs": "^1.29.0", @@ -9294,7 +9293,8 @@ "node_modules/exponential-backoff": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", - "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==" + "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==", + "peer": true }, "node_modules/extend": { "version": "3.0.2", @@ -29643,7 +29643,8 @@ "exponential-backoff": { "version": "3.1.1", "resolved": "https://registry.npmjs.org/exponential-backoff/-/exponential-backoff-3.1.1.tgz", - "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==" + "integrity": "sha512-dX7e/LHVJ6W3DE1MHWi9S1EYzDESENfLrYohG2G++ovZrYOkm4Knwa0mc1cn84xJOR4KEU0WSchhLbd0UklbHw==", + "peer": true }, "extend": { "version": "3.0.2", diff --git a/webui/package.json b/webui/package.json index d8c4260d5b7..d9f585a00b6 100644 --- a/webui/package.json +++ b/webui/package.json @@ -28,7 +28,6 @@ "bootstrap": "^5.3.2", "csstype": "^3.1.3", "dayjs": "^1.11.10", - "exponential-backoff": "^3.1.1", "lodash": "^4.17.21", "p-map": "^7.0.0", "prismjs": "^1.29.0", diff --git a/webui/src/lib/api/index.js b/webui/src/lib/api/index.js index 85648ac2a09..6956a48066f 100644 --- a/webui/src/lib/api/index.js +++ b/webui/src/lib/api/index.js @@ -616,6 +616,26 @@ class Pulls { return response.json() } + async merge(repoId, pullId) { + const response = await apiRequest(`/repositories/${encodeURIComponent(repoId)}/pulls/${encodeURIComponent(pullId)}/merge`, { + method: 'PUT', + }); + if (response.status !== 200) { + const baseMessage = 'Could not merge pull request'; + switch (response.status) { + case 400: + case 401: + case 403: + case 404: + case 409: + case 412: + throw new Error(`${baseMessage}: ${(await response.json()).message}`); + default: + throw new Error(`${baseMessage} (status = ${response.status}).`); + } + } + } + async update(repoId, pullId, pullDetails) { const response = await apiRequest(`/repositories/${encodeURIComponent(repoId)}/pulls/${encodeURIComponent(pullId)}`, { method: 'PATCH', diff --git a/webui/src/pages/repositories/repository/pulls/createPull.jsx b/webui/src/pages/repositories/repository/pulls/createPull.jsx index 8b4b890f537..9a835095529 100644 --- a/webui/src/pages/repositories/repository/pulls/createPull.jsx +++ b/webui/src/pages/repositories/repository/pulls/createPull.jsx @@ -73,7 +73,7 @@ const CreatePullForm = ({repo, reference, compare}) => { {error && setError(null)}/>}