summaryrefslogtreecommitdiff
path: root/app/assets/javascripts/api.js
diff options
context:
space:
mode:
authorDenys Mishunov <dmishunov@gitlab.com>2019-03-01 17:33:18 +0100
committerDenys Mishunov <dmishunov@gitlab.com>2019-03-04 18:10:55 +0100
commita1b0b3e4ebb61e952b6e60e7be05bd96286bc298 (patch)
treed6dce2abed1ad4cccbcfe7a6ddce1fbaaf05cdce /app/assets/javascripts/api.js
parent615c14b28990489d99371b7ffdb57fe54d463e64 (diff)
downloadgitlab-ce-a1b0b3e4ebb61e952b6e60e7be05bd96286bc298.tar.gz
Extended Web IDE API to get MRs for a certain branch in a project
New `Api.projectMergeRequests` allows: - to query for all MRs on a project without specifying `mergeRequestId` - to filter the returned MRs using parameters from https://bit.ly/2H7We4V The new API request is used for fetching information about MRs associated with a particular branch in Web IDE to have IdeSidebar behave consistently in both scenarios: - getting to a branch from and MR (where we already have info about relevant MR), or - getting to a branch somehow differently directly For cases where there are several merge requests that the current branch is associated with, mark the most recent one as 'current' Closes https://gitlab.com/gitlab-org/gitlab-ce/issues/49663
Diffstat (limited to 'app/assets/javascripts/api.js')
-rw-r--r--app/assets/javascripts/api.js17
1 files changed, 17 insertions, 0 deletions
diff --git a/app/assets/javascripts/api.js b/app/assets/javascripts/api.js
index 85eb08cc97d..8754c253881 100644
--- a/app/assets/javascripts/api.js
+++ b/app/assets/javascripts/api.js
@@ -12,6 +12,7 @@ const Api = {
projectsPath: '/api/:version/projects.json',
projectPath: '/api/:version/projects/:id',
projectLabelsPath: '/:namespace_path/:project_path/labels',
+ projectMergeRequestsPath: '/api/:version/projects/:id/merge_requests',
projectMergeRequestPath: '/api/:version/projects/:id/merge_requests/:mrid',
projectMergeRequestChangesPath: '/api/:version/projects/:id/merge_requests/:mrid/changes',
projectMergeRequestVersionsPath: '/api/:version/projects/:id/merge_requests/:mrid/versions',
@@ -111,6 +112,22 @@ const Api = {
return axios.get(url);
},
+ /**
+ * Get all Merge Requests for a project, eventually filtering based on
+ * supplied parameters
+ * @param projectPath
+ * @param params
+ * @returns {Promise}
+ */
+ projectMergeRequests(projectPath, params = {}) {
+ const url = Api.buildUrl(Api.projectMergeRequestsPath).replace(
+ ':id',
+ encodeURIComponent(projectPath),
+ );
+
+ return axios.get(url, { params });
+ },
+
// Return Merge Request for project
projectMergeRequest(projectPath, mergeRequestId, params = {}) {
const url = Api.buildUrl(Api.projectMergeRequestPath)