Converted protected_branch_edit.js to use axios
This commit is contained in:
parent
e6cd217df6
commit
a32065eeae
1 changed files with 18 additions and 22 deletions
|
@ -1,5 +1,5 @@
|
||||||
/* eslint-disable no-new */
|
import flash from '../flash';
|
||||||
import Flash from '../flash';
|
import axios from '../lib/utils/axios_utils';
|
||||||
import ProtectedBranchAccessDropdown from './protected_branch_access_dropdown';
|
import ProtectedBranchAccessDropdown from './protected_branch_access_dropdown';
|
||||||
|
|
||||||
export default class ProtectedBranchEdit {
|
export default class ProtectedBranchEdit {
|
||||||
|
@ -38,12 +38,7 @@ export default class ProtectedBranchEdit {
|
||||||
this.$allowedToMergeDropdown.disable();
|
this.$allowedToMergeDropdown.disable();
|
||||||
this.$allowedToPushDropdown.disable();
|
this.$allowedToPushDropdown.disable();
|
||||||
|
|
||||||
$.ajax({
|
axios.patch(this.$wrap.data('url'), {
|
||||||
type: 'POST',
|
|
||||||
url: this.$wrap.data('url'),
|
|
||||||
dataType: 'json',
|
|
||||||
data: {
|
|
||||||
_method: 'PATCH',
|
|
||||||
protected_branch: {
|
protected_branch: {
|
||||||
merge_access_levels_attributes: [{
|
merge_access_levels_attributes: [{
|
||||||
id: this.$allowedToMergeDropdown.data('access-level-id'),
|
id: this.$allowedToMergeDropdown.data('access-level-id'),
|
||||||
|
@ -54,13 +49,14 @@ export default class ProtectedBranchEdit {
|
||||||
access_level: $allowedToPushInput.val(),
|
access_level: $allowedToPushInput.val(),
|
||||||
}],
|
}],
|
||||||
},
|
},
|
||||||
},
|
}).then(() => {
|
||||||
error() {
|
|
||||||
new Flash('Failed to update branch!', 'alert', document.querySelector('.js-protected-branches-list'));
|
|
||||||
},
|
|
||||||
}).always(() => {
|
|
||||||
this.$allowedToMergeDropdown.enable();
|
this.$allowedToMergeDropdown.enable();
|
||||||
this.$allowedToPushDropdown.enable();
|
this.$allowedToPushDropdown.enable();
|
||||||
|
}).catch(() => {
|
||||||
|
this.$allowedToMergeDropdown.enable();
|
||||||
|
this.$allowedToPushDropdown.enable();
|
||||||
|
|
||||||
|
flash('Failed to update branch!', 'alert', document.querySelector('.js-protected-branches-list'));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue