Skip to content
This repository was archived by the owner on Aug 31, 2023. It is now read-only.

Commit a961eb6

Browse files
committed
Add comments
1 parent 6015665 commit a961eb6

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

js/content.js

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,16 @@
22
'use strict';
33

44
class GitLabApiClient {
5+
/**
6+
* The GitLab API client used by the extension. No tokens or authentication needed as every requests are
7+
* performed from inside the context of the page (GitLab allows API calls if they comes from the site).
8+
*/
59
constructor(baseUrl) {
610
this.baseUrl = baseUrl;
711
}
812

913
/**
10-
* Create an `URL` object representing the full URL to the given GitLab API endpoint.
14+
* Creates an `URL` object representing the full URL to the given GitLab API endpoint.
1115
*/
1216
createEndpointUrl(endpoint, queryStringParameters = null) {
1317
let url = new URL(this.baseUrl + endpoint);
@@ -21,7 +25,10 @@
2125
return url;
2226
}
2327

24-
sendRequest(method, endpoint, callback, queryStringParameters = null) {
28+
/**
29+
* Sends an HTTP request to the GitLab API.
30+
*/
31+
sendRequest(callback, method, endpoint, queryStringParameters = null) {
2532
let xhr = new XMLHttpRequest();
2633

2734
xhr.responseType = 'json';
@@ -37,17 +44,17 @@
3744
}
3845

3946
/**
40-
* Fetch details about the given Merge Requests IDs.
47+
* Fetch details about the given Merge Requests IDs in the given project ID.
4148
*/
42-
getMergeRequests(projectId, mergeRequestIds, callback) {
49+
getProjectMergeRequests(callback, projectId, mergeRequestIds) {
4350
let queryStringParameters = mergeRequestIds.map(function(mergeRequestId) {
4451
return ['iids[]', mergeRequestId];
4552
});
4653

4754
this.sendRequest(
55+
callback,
4856
'GET',
4957
'projects/' + projectId + '/merge_requests',
50-
callback,
5158
queryStringParameters
5259
);
5360
}
@@ -139,16 +146,16 @@
139146
fetchMergeRequestsDetails(mergeRequestIds) {
140147
let self = this;
141148

142-
this.apiClient.getMergeRequests(
143-
this.currentProjectId,
144-
mergeRequestIds,
149+
this.apiClient.getProjectMergeRequests(
145150
function() {
146151
if (this.status == 200) {
147152
self.updateMergeRequestsNodes(this.response);
148153
} else {
149154
console.error('Got error from GitLab:', this.status, this.response);
150155
}
151-
}
156+
},
157+
this.currentProjectId,
158+
mergeRequestIds
152159
);
153160
}
154161

0 commit comments

Comments
 (0)