提交 725a4fef 编写于 作者: J Jacob Schatz 提交者: Mike Greiling

Add thenable ajax calls.

上级 91d3e6d9
......@@ -99,15 +99,13 @@ const Api = {
commitMultiple(id, data, callback) {
const url = Api.buildUrl(Api.commitPath)
.replace(':id', id);
return $.ajax({
return this.wrapAjaxCall({
url,
type: 'POST',
contentType: 'application/json; charset=utf-8',
data: JSON.stringify(data),
dataType: 'json',
})
.done(commitData => callback(commitData))
.fail(message => callback(message.responseJSON));
});
},
// Return text for a specific license
......
......@@ -42,10 +42,11 @@ export default {
actions,
};
Store.submitCommitsLoading = true;
Service.commitFiles(payload, this.resetCommitState);
Service.commitFiles(payload)
.then(this.resetCommitState);
},
resetCommitState() {
resetCommitState(data) {
this.submitCommitsLoading = false;
this.changedFiles = [];
this.commitMessage = '';
......
......@@ -65,14 +65,14 @@ const RepoService = {
return urlArray.join('/');
},
commitFiles(payload, cb) {
Api.commitMultiple(Store.projectId, payload, (data) => {
commitFiles(payload) {
return Api.commitMultiple(Store.projectId, payload)
.then((data) => {
if (data.short_id && data.stats) {
Flash(`Your changes have been committed. Commit ${data.short_id} with ${data.stats.additions} additions, ${data.stats.deletions} deletions.`, 'notice');
} else {
Flash(data.message);
}
cb();
});
},
};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册