Merge "Update gr-rest-api for closure compilation"
This commit is contained in:
commit
c1eb61280d
@ -94,10 +94,12 @@
|
||||
* Doesn't do error checking. Supports cancel condition. Performs auth.
|
||||
* Validates auth expiry errors.
|
||||
* @param {string} url
|
||||
* @param {function(response, error)} opt_errFn
|
||||
* @param {function()} opt_cancelCondition
|
||||
* @param {Object=} opt_params URL params, key-value hash.
|
||||
* @param {Object=} opt_options Fetch options.
|
||||
* @param {?function(?Response, string)=} opt_errFn
|
||||
* passed as null sometimes.
|
||||
* @param {?function()=} opt_cancelCondition
|
||||
* passed as null sometimes.
|
||||
* @param {?Object=} opt_params URL params, key-value hash.
|
||||
* @param {?Object=} opt_options Fetch options.
|
||||
*/
|
||||
_fetchRawJSON(url, opt_errFn, opt_cancelCondition, opt_params,
|
||||
opt_options) {
|
||||
@ -119,7 +121,7 @@
|
||||
return;
|
||||
}
|
||||
if (opt_errFn) {
|
||||
opt_errFn.call(null, null, err);
|
||||
opt_errFn.call(undefined, null, err);
|
||||
} else {
|
||||
this.fire('network-error', {error: err});
|
||||
}
|
||||
@ -132,10 +134,12 @@
|
||||
* Returns a Promise that resolves to a parsed response.
|
||||
* Same as {@link _fetchRawJSON}, plus error handling.
|
||||
* @param {string} url
|
||||
* @param {function(response, error)} opt_errFn
|
||||
* @param {function()} opt_cancelCondition
|
||||
* @param {Object=} opt_params URL params, key-value hash.
|
||||
* @param {Object=} opt_options Fetch options.
|
||||
* @param {?function(?Response, string=)=} opt_errFn
|
||||
* passed as null sometimes.
|
||||
* @param {?function()=} opt_cancelCondition
|
||||
* passed as null sometimes.
|
||||
* @param {?Object=} opt_params URL params, key-value hash.
|
||||
* @param {?Object=} opt_options Fetch options.
|
||||
*/
|
||||
fetchJSON(url, opt_errFn, opt_cancelCondition, opt_params, opt_options) {
|
||||
return this._fetchRawJSON(
|
||||
@ -156,6 +160,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {?Object=} opt_params URL params, key-value hash.
|
||||
* @return {string}
|
||||
*/
|
||||
_urlWithParams(url, opt_params) {
|
||||
if (!opt_params) { return this.getBaseUrl() + url; }
|
||||
|
||||
@ -204,6 +213,11 @@
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {?Object} config
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
createProject(config, opt_errFn, opt_ctx) {
|
||||
if (!config.name) { return ''; }
|
||||
const encodeName = encodeURIComponent(config.name);
|
||||
@ -211,6 +225,11 @@
|
||||
opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {?Object} config
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
createGroup(config, opt_errFn, opt_ctx) {
|
||||
if (!config.name) { return ''; }
|
||||
const encodeName = encodeURIComponent(config.name);
|
||||
@ -223,6 +242,12 @@
|
||||
return this._fetchSharedCacheURL('/groups/' + encodeName + '/detail');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} project
|
||||
* @param {string} ref
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
deleteProjectBranches(project, ref, opt_errFn, opt_ctx) {
|
||||
if (!project || !ref) {
|
||||
return '';
|
||||
@ -234,6 +259,12 @@
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} project
|
||||
* @param {string} ref
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
deleteProjectTags(project, ref, opt_errFn, opt_ctx) {
|
||||
if (!project || !ref) {
|
||||
return '';
|
||||
@ -245,6 +276,13 @@
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} branch
|
||||
* @param {string} revision
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
createProjectBranch(name, branch, revision, opt_errFn, opt_ctx) {
|
||||
if (!name || !branch || !revision) { return ''; }
|
||||
const encodeName = encodeURIComponent(name);
|
||||
@ -254,6 +292,13 @@
|
||||
revision, opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {string} tag
|
||||
* @param {string} revision
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
createProjectTag(name, tag, revision, opt_errFn, opt_ctx) {
|
||||
if (!name || !tag || !revision) { return ''; }
|
||||
const encodeName = encodeURIComponent(name);
|
||||
@ -324,6 +369,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {?Object} prefs
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
savePreferences(prefs, opt_errFn, opt_ctx) {
|
||||
// Note (Issue 5142): normalize the download scheme with lower case before
|
||||
// saving.
|
||||
@ -335,6 +385,11 @@
|
||||
opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {?Object} prefs
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
saveDiffPreferences(prefs, opt_errFn, opt_ctx) {
|
||||
// Invalidate the cache.
|
||||
this._cache['/accounts/self/preferences.diff'] = undefined;
|
||||
@ -354,16 +409,31 @@
|
||||
return this._fetchSharedCacheURL('/accounts/self/emails');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
addAccountEmail(email, opt_errFn, opt_ctx) {
|
||||
return this.send('PUT', '/accounts/self/emails/' +
|
||||
encodeURIComponent(email), null, opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
deleteAccountEmail(email, opt_errFn, opt_ctx) {
|
||||
return this.send('DELETE', '/accounts/self/emails/' +
|
||||
encodeURIComponent(email), null, opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} email
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
setPreferredAccountEmail(email, opt_errFn, opt_ctx) {
|
||||
return this.send('PUT', '/accounts/self/emails/' +
|
||||
encodeURIComponent(email) + '/preferred', null,
|
||||
@ -384,6 +454,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} name
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
setAccountName(name, opt_errFn, opt_ctx) {
|
||||
return this.send('PUT', '/accounts/self/name', {name}, opt_errFn,
|
||||
opt_ctx).then(response => {
|
||||
@ -401,6 +476,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} status
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
setAccountStatus(status, opt_errFn, opt_ctx) {
|
||||
return this.send('PUT', '/accounts/self/status', {status},
|
||||
opt_errFn, opt_ctx).then(response => {
|
||||
@ -426,6 +506,9 @@
|
||||
return this._fetchSharedCacheURL('/accounts/self/agreements');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string=} opt_params
|
||||
*/
|
||||
getAccountCapabilities(opt_params) {
|
||||
let queryString = '';
|
||||
if (opt_params) {
|
||||
@ -500,6 +583,11 @@
|
||||
return this._fetchSharedCacheURL('/accounts/self/watched.projects');
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} projects
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
saveWatchedProjects(projects, opt_errFn, opt_ctx) {
|
||||
return this.send('POST', '/accounts/self/watched.projects', projects,
|
||||
opt_errFn, opt_ctx)
|
||||
@ -508,11 +596,20 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} projects
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
deleteWatchedProjects(projects, opt_errFn, opt_ctx) {
|
||||
return this.send('POST', '/accounts/self/watched.projects:delete',
|
||||
projects, opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} url
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
*/
|
||||
_fetchSharedCacheURL(url, opt_errFn) {
|
||||
if (this._sharedFetchPromises[url]) {
|
||||
return this._sharedFetchPromises[url];
|
||||
@ -540,13 +637,13 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {!number} opt_changesPerPage
|
||||
* @param {!string|Array<string>} opt_query A query or an array of queries.
|
||||
* @param {!number} opt_offset
|
||||
* @param {!Object} opt_options
|
||||
* @return {Array<Object>|Array<Array<Object>>} If opt_query is an array,
|
||||
* fetchJSON will return an array of arrays of changeInfos. If it is
|
||||
* unspecified or a string, fetchJSON will return an array of
|
||||
* @param {number=} opt_changesPerPage
|
||||
* @param {string|!Array<string>=} opt_query A query or an array of queries.
|
||||
* @param {number|string=} opt_offset
|
||||
* @param {!Object=} opt_options
|
||||
* @return {?Array<!Object>|?Array<!Array<!Object>>} If opt_query is an
|
||||
* array, fetchJSON will return an array of arrays of changeInfos. If it
|
||||
* is unspecified or a string, fetchJSON will return an array of
|
||||
* changeInfos.
|
||||
*/
|
||||
getChanges(opt_changesPerPage, opt_query, opt_offset, opt_options) {
|
||||
@ -587,7 +684,7 @@
|
||||
|
||||
/**
|
||||
* Inserts a change into _projectLookup iff it has a valid structure.
|
||||
* @param {!Object} change
|
||||
* @param {?{ _number: (number|string) }} change
|
||||
*/
|
||||
_maybeInsertInLookup(change) {
|
||||
if (change && change.project && change._number) {
|
||||
@ -595,11 +692,25 @@
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* TODO (beckysiegel) this needs to be rewritten with the optional param
|
||||
* at the end.
|
||||
*
|
||||
* @param {number|string} changeNum
|
||||
* @param {?number|string=} opt_patchNum passed as null sometimes.
|
||||
* @param {?=} endpoint
|
||||
* @return {string}
|
||||
*/
|
||||
getChangeActionURL(changeNum, opt_patchNum, endpoint) {
|
||||
return this._changeBaseURL(changeNum, opt_patchNum)
|
||||
.then(url => url + endpoint);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
getChangeDetail(changeNum, opt_errFn, opt_cancelCondition) {
|
||||
const options = this.listChangesOptionsToHex(
|
||||
this.ListChangesOption.ALL_REVISIONS,
|
||||
@ -615,6 +726,11 @@
|
||||
.then(GrReviewerUpdatesParser.parse);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
getDiffChangeDetail(changeNum, opt_errFn, opt_cancelCondition) {
|
||||
const params = this.listChangesOptionsToHex(
|
||||
this.ListChangesOption.ALL_REVISIONS
|
||||
@ -623,6 +739,11 @@
|
||||
opt_cancelCondition);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
_getChangeDetail(changeNum, params, opt_errFn,
|
||||
opt_cancelCondition) {
|
||||
return this.getChangeActionURL(changeNum, null, '/detail').then(url => {
|
||||
@ -651,10 +772,18 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} patchNum
|
||||
*/
|
||||
getChangeCommitInfo(changeNum, patchNum) {
|
||||
return this._getChangeURLAndFetch(changeNum, '/commit?links', patchNum);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {!Promise<?Object>} patchRange
|
||||
*/
|
||||
getChangeFiles(changeNum, patchRange) {
|
||||
let endpoint = '/files';
|
||||
if (patchRange.basePatchNum !== 'PARENT') {
|
||||
@ -669,12 +798,22 @@
|
||||
this._normalizeChangeFilesResponse.bind(this));
|
||||
},
|
||||
|
||||
/**
|
||||
* The closure compiler doesn't realize this.specialFilePathCompare is
|
||||
* valid.
|
||||
* @suppress {checkTypes}
|
||||
*/
|
||||
getChangeFilePathsAsSpeciallySortedArray(changeNum, patchRange) {
|
||||
return this.getChangeFiles(changeNum, patchRange).then(files => {
|
||||
return Object.keys(files).sort(this.specialFilePathCompare);
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* The closure compiler doesn't realize this.specialFilePathCompare is
|
||||
* valid.
|
||||
* @suppress {checkTypes}
|
||||
*/
|
||||
_normalizeChangeFilesResponse(response) {
|
||||
if (!response) { return []; }
|
||||
const paths = Object.keys(response).sort(this.specialFilePathCompare);
|
||||
@ -702,6 +841,12 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {string} inputVal
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
getChangeSuggestedReviewers(changeNum, inputVal, opt_errFn) {
|
||||
const params = {n: 10};
|
||||
if (inputVal) { params.q = inputVal; }
|
||||
@ -720,6 +865,12 @@
|
||||
return filter;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @param {number} groupsPerPage
|
||||
* @param {number=} opt_offset
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getGroups(filter, groupsPerPage, opt_offset) {
|
||||
const offset = opt_offset || 0;
|
||||
|
||||
@ -729,6 +880,12 @@
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @param {number} projectsPerPage
|
||||
* @param {number=} opt_offset
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getProjects(filter, projectsPerPage, opt_offset) {
|
||||
const offset = opt_offset || 0;
|
||||
|
||||
@ -743,6 +900,13 @@
|
||||
'PUT', `/projects/${encodeURIComponent(project)}/HEAD`, {ref});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @param {string} project
|
||||
* @param {number} projectsBranchesPerPage
|
||||
* @param {number=} opt_offset
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getProjectBranches(filter, project, projectsBranchesPerPage, opt_offset) {
|
||||
const offset = opt_offset || 0;
|
||||
|
||||
@ -753,6 +917,13 @@
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @param {string} project
|
||||
* @param {number} projectsTagsPerPage
|
||||
* @param {number=} opt_offset
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getProjectTags(filter, project, projectsTagsPerPage, opt_offset) {
|
||||
const offset = opt_offset || 0;
|
||||
|
||||
@ -763,6 +934,12 @@
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} filter
|
||||
* @param {number} pluginsPerPage
|
||||
* @param {number=} opt_offset
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getPlugins(filter, pluginsPerPage, opt_offset) {
|
||||
const offset = opt_offset || 0;
|
||||
|
||||
@ -772,12 +949,24 @@
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} inputVal
|
||||
* @param {number} opt_n
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
getSuggestedGroups(inputVal, opt_n, opt_errFn, opt_ctx) {
|
||||
const params = {s: inputVal};
|
||||
if (opt_n) { params.n = opt_n; }
|
||||
return this.fetchJSON('/groups/', opt_errFn, opt_ctx, params);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} inputVal
|
||||
* @param {number} opt_n
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
getSuggestedProjects(inputVal, opt_n, opt_errFn, opt_ctx) {
|
||||
const params = {
|
||||
m: inputVal,
|
||||
@ -788,6 +977,12 @@
|
||||
return this.fetchJSON('/projects/', opt_errFn, opt_ctx, params);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} inputVal
|
||||
* @param {number} opt_n
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
getSuggestedAccounts(inputVal, opt_n, opt_errFn, opt_ctx) {
|
||||
if (!inputVal) {
|
||||
return Promise.resolve([]);
|
||||
@ -880,6 +1075,14 @@
|
||||
return this._getChangeURLAndFetch(changeNum, '/files?reviewed', patchNum);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} patchNum
|
||||
* @param {string} path
|
||||
* @param {boolean} reviewed
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
saveFileReviewed(changeNum, patchNum, path, reviewed, opt_errFn, opt_ctx) {
|
||||
const method = reviewed ? 'PUT' : 'DELETE';
|
||||
const e = `/files/${encodeURIComponent(path)}/reviewed`;
|
||||
@ -887,6 +1090,13 @@
|
||||
opt_errFn, opt_ctx);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} patchNum
|
||||
* @param {!Object} review
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {?=} opt_ctx
|
||||
*/
|
||||
saveChangeReview(changeNum, patchNum, review, opt_errFn, opt_ctx) {
|
||||
const promises = [
|
||||
this.awaitPendingDiffDrafts(),
|
||||
@ -963,12 +1173,23 @@
|
||||
return this.send(method, url);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} method
|
||||
* @param {string} url
|
||||
* @param {?string|number|Object=} opt_body passed as null sometimes
|
||||
* and also apparently a number. TODO (beckysiegel) remove need for
|
||||
* number at least.
|
||||
* @param {?function(?Response, string=)=} opt_errFn
|
||||
* passed as null sometimes.
|
||||
* @param {?=} opt_ctx
|
||||
* @param {?string=} opt_contentType
|
||||
*/
|
||||
send(method, url, opt_body, opt_errFn, opt_ctx, opt_contentType) {
|
||||
const options = {method};
|
||||
if (opt_body) {
|
||||
options.headers = new Headers({
|
||||
'Content-Type': opt_contentType || 'application/json',
|
||||
});
|
||||
options.headers = new Headers();
|
||||
options.headers.set(
|
||||
'Content-Type', opt_contentType || 'application/json');
|
||||
if (typeof opt_body !== 'string') {
|
||||
opt_body = JSON.stringify(opt_body);
|
||||
}
|
||||
@ -994,6 +1215,14 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} basePatchNum
|
||||
* @param {number|string} patchNum
|
||||
* @param {string} path
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
* @param {function()=} opt_cancelCondition
|
||||
*/
|
||||
getDiff(changeNum, basePatchNum, patchNum, path,
|
||||
opt_errFn, opt_cancelCondition) {
|
||||
const params = {
|
||||
@ -1010,6 +1239,12 @@
|
||||
opt_errFn, opt_cancelCondition, params);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string=} opt_basePatchNum
|
||||
* @param {number|string=} opt_patchNum
|
||||
* @param {string=} opt_path
|
||||
*/
|
||||
getDiffComments(changeNum, opt_basePatchNum, opt_patchNum, opt_path) {
|
||||
return this._getDiffComments(changeNum, '/comments', opt_basePatchNum,
|
||||
opt_patchNum, opt_path);
|
||||
@ -1026,10 +1261,10 @@
|
||||
* empty object.
|
||||
*
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string} opt_basePatchNum
|
||||
* @param {number|string} opt_patchNum
|
||||
* @param {string} opt_path
|
||||
* @return {Promise<Object>}
|
||||
* @param {number|string=} opt_basePatchNum
|
||||
* @param {number|string=} opt_patchNum
|
||||
* @param {string=} opt_path
|
||||
* @return {!Promise<?Object>}
|
||||
*/
|
||||
getDiffDrafts(changeNum, opt_basePatchNum, opt_patchNum, opt_path) {
|
||||
return this.getLoggedIn().then(loggedIn => {
|
||||
@ -1062,6 +1297,13 @@
|
||||
return comments;
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {string} endpoint
|
||||
* @param {number|string=} opt_basePatchNum
|
||||
* @param {number|string=} opt_patchNum
|
||||
* @param {string=} opt_path
|
||||
*/
|
||||
_getDiffComments(changeNum, endpoint, opt_basePatchNum,
|
||||
opt_patchNum, opt_path) {
|
||||
/**
|
||||
@ -1122,6 +1364,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {string} endpoint
|
||||
* @param {number|string=} opt_patchNum
|
||||
*/
|
||||
_getDiffCommentsFetchURL(changeNum, endpoint, opt_patchNum) {
|
||||
return this._changeBaseURL(changeNum, opt_patchNum)
|
||||
.then(url => url + endpoint);
|
||||
@ -1144,8 +1391,8 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* @returns {Promise} A promise that resolves when all pending diff draft
|
||||
* sends have resolved.
|
||||
* @returns {!Promise<undefined>} A promise that resolves when all pending
|
||||
* diff draft sends have resolved.
|
||||
*/
|
||||
awaitPendingDiffDrafts() {
|
||||
return Promise.all(this._pendingRequests[Requests.SEND_DIFF_DRAFT] || [])
|
||||
@ -1192,6 +1439,12 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} changeId
|
||||
* @param {string|number} patchNum
|
||||
* @param {string} path
|
||||
* @param {number=} opt_parentIndex
|
||||
*/
|
||||
getChangeFileContents(changeId, patchNum, path, opt_parentIndex) {
|
||||
const parent = typeof opt_parentIndex === 'number' ?
|
||||
'?parent=' + opt_parentIndex : '';
|
||||
@ -1244,8 +1497,8 @@
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {string} changeNum
|
||||
* @param {number|string=} opt_patchNum
|
||||
* @param {number|string} changeNum
|
||||
* @param {?number|string=} opt_patchNum passed as null sometimes.
|
||||
* @param {string=} opt_project
|
||||
* @return {!Promise<string>}
|
||||
*/
|
||||
@ -1344,6 +1597,10 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string=} opt_message
|
||||
*/
|
||||
startWorkInProgress(changeNum, opt_message) {
|
||||
const payload = {};
|
||||
if (opt_message) {
|
||||
@ -1357,6 +1614,11 @@
|
||||
});
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {number|string} changeNum
|
||||
* @param {number|string=} opt_body
|
||||
* @param {function(?Response, string=)=} opt_errFn
|
||||
*/
|
||||
startReview(changeNum, opt_body, opt_errFn) {
|
||||
return this.getChangeURLAndSend(changeNum, 'POST', null, '/ready',
|
||||
opt_body, opt_errFn);
|
||||
@ -1372,8 +1634,8 @@
|
||||
/**
|
||||
* Given a changeNum, gets the change.
|
||||
*
|
||||
* @param {string} changeNum
|
||||
* @return {Promise<Object>} The change
|
||||
* @param {number|string} changeNum
|
||||
* @return {!Promise<?Object>} The change
|
||||
*/
|
||||
getChange(changeNum) {
|
||||
// Cannot use _changeBaseURL, as this function is used by _projectLookup.
|
||||
@ -1382,7 +1644,7 @@
|
||||
|
||||
/**
|
||||
* @param {string|number} changeNum
|
||||
* @param {string} project
|
||||
* @param {string=} project
|
||||
*/
|
||||
setInProjectLookup(changeNum, project) {
|
||||
if (this._projectLookup[changeNum] &&
|
||||
@ -1399,7 +1661,7 @@
|
||||
* _projectLookup with the project for that change, and returns the project.
|
||||
*
|
||||
* @param {string|number} changeNum
|
||||
* @return {Promise<string>}
|
||||
* @return {!Promise<string|undefined>}
|
||||
*/
|
||||
_getFromProjectLookup(changeNum) {
|
||||
const project = this._projectLookup[changeNum];
|
||||
|
Loading…
Reference in New Issue
Block a user