Commit a32065ee authored by Phil Hughes's avatar Phil Hughes

Converted protected_branch_edit.js to use axios

parent e6cd217d
/* 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,29 +38,25 @@ export default class ProtectedBranchEdit { ...@@ -38,29 +38,25 @@ 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', protected_branch: {
url: this.$wrap.data('url'), merge_access_levels_attributes: [{
dataType: 'json', id: this.$allowedToMergeDropdown.data('access-level-id'),
data: { access_level: $allowedToMergeInput.val(),
_method: 'PATCH', }],
protected_branch: { push_access_levels_attributes: [{
merge_access_levels_attributes: [{ id: this.$allowedToPushDropdown.data('access-level-id'),
id: this.$allowedToMergeDropdown.data('access-level-id'), access_level: $allowedToPushInput.val(),
access_level: $allowedToMergeInput.val(), }],
}],
push_access_levels_attributes: [{
id: this.$allowedToPushDropdown.data('access-level-id'),
access_level: $allowedToPushInput.val(),
}],
},
}, },
error() { }).then(() => {
new Flash('Failed to update branch!', 'alert', document.querySelector('.js-protected-branches-list')); this.$allowedToMergeDropdown.enable();
}, this.$allowedToPushDropdown.enable();
}).always(() => { }).catch(() => {
this.$allowedToMergeDropdown.enable(); this.$allowedToMergeDropdown.enable();
this.$allowedToPushDropdown.enable(); this.$allowedToPushDropdown.enable();
flash('Failed to update branch!', 'alert', document.querySelector('.js-protected-branches-list'));
}); });
} }
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment