Convert merge_conflict_service.js to axios
This commit is contained in:
parent
05a3479c9e
commit
8750507b5d
|
@ -1,4 +1,5 @@
|
|||
/* eslint-disable no-param-reassign, comma-dangle */
|
||||
import axios from '../lib/utils/axios_utils';
|
||||
|
||||
((global) => {
|
||||
global.mergeConflicts = global.mergeConflicts || {};
|
||||
|
@ -10,20 +11,11 @@
|
|||
}
|
||||
|
||||
fetchConflictsData() {
|
||||
return $.ajax({
|
||||
dataType: 'json',
|
||||
url: this.conflictsPath
|
||||
});
|
||||
return axios.get(this.conflictsPath);
|
||||
}
|
||||
|
||||
submitResolveConflicts(data) {
|
||||
return $.ajax({
|
||||
url: this.resolveConflictsPath,
|
||||
data: JSON.stringify(data),
|
||||
contentType: 'application/json',
|
||||
dataType: 'json',
|
||||
method: 'POST'
|
||||
});
|
||||
return axios.post(this.resolveConflictsPath, data);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -38,24 +38,22 @@ $(() => {
|
|||
showDiffViewTypeSwitcher() { return mergeConflictsStore.fileTextTypePresent(); }
|
||||
},
|
||||
created() {
|
||||
mergeConflictsService
|
||||
.fetchConflictsData()
|
||||
.done((data) => {
|
||||
mergeConflictsService.fetchConflictsData()
|
||||
.then(({ data }) => {
|
||||
if (data.type === 'error') {
|
||||
mergeConflictsStore.setFailedRequest(data.message);
|
||||
} else {
|
||||
mergeConflictsStore.setConflictsData(data);
|
||||
}
|
||||
})
|
||||
.error(() => {
|
||||
mergeConflictsStore.setFailedRequest();
|
||||
})
|
||||
.always(() => {
|
||||
|
||||
mergeConflictsStore.setLoadingState(false);
|
||||
|
||||
this.$nextTick(() => {
|
||||
syntaxHighlight($('.js-syntax-highlight'));
|
||||
});
|
||||
})
|
||||
.catch(() => {
|
||||
mergeConflictsStore.setFailedRequest();
|
||||
});
|
||||
},
|
||||
methods: {
|
||||
|
@ -82,10 +80,10 @@ $(() => {
|
|||
|
||||
mergeConflictsService
|
||||
.submitResolveConflicts(mergeConflictsStore.getCommitData())
|
||||
.done((data) => {
|
||||
.then(({ data }) => {
|
||||
window.location.href = data.redirect_to;
|
||||
})
|
||||
.error(() => {
|
||||
.catch(() => {
|
||||
mergeConflictsStore.setSubmitState(false);
|
||||
new Flash('Failed to save merge conflicts resolutions. Please try again!');
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue