summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPhil Hughes <me@iamphill.com>2018-02-02 10:54:36 +0000
committerPhil Hughes <me@iamphill.com>2018-02-05 09:40:59 +0000
commitdeaf6aee2bf0aa0d87a70f536a1064eded573b6b (patch)
tree127ef1b88da410b455546a18fb105b9b43206216
parenta32065eeae5d71f0897c9075e11a2d56b8238349 (diff)
downloadgitlab-ce-deaf6aee2bf0aa0d87a70f536a1064eded573b6b.tar.gz
Converted protected_tag_edit.js to use axios
-rw-r--r--app/assets/javascripts/protected_tags/protected_tag_edit.js31
1 files changed, 13 insertions, 18 deletions
diff --git a/app/assets/javascripts/protected_tags/protected_tag_edit.js b/app/assets/javascripts/protected_tags/protected_tag_edit.js
index dad0ad25b65..21a258cf93c 100644
--- a/app/assets/javascripts/protected_tags/protected_tag_edit.js
+++ b/app/assets/javascripts/protected_tags/protected_tag_edit.js
@@ -1,5 +1,5 @@
-/* eslint-disable no-new */
-import Flash from '../flash';
+import flash from '../flash';
+import axios from '../lib/utils/axios_utils';
import ProtectedTagAccessDropdown from './protected_tag_access_dropdown';
export default class ProtectedTagEdit {
@@ -28,24 +28,19 @@ export default class ProtectedTagEdit {
this.$allowedToCreateDropdownButton.disable();
- $.ajax({
- type: 'POST',
- url: this.$wrap.data('url'),
- dataType: 'json',
- data: {
- _method: 'PATCH',
- protected_tag: {
- create_access_levels_attributes: [{
- id: this.$allowedToCreateDropdownButton.data('access-level-id'),
- access_level: $allowedToCreateInput.val(),
- }],
- },
+ axios.patch(this.$wrap.data('url'), {
+ protected_tag: {
+ create_access_levels_attributes: [{
+ id: this.$allowedToCreateDropdownButton.data('access-level-id'),
+ access_level: $allowedToCreateInput.val(),
+ }],
},
- error() {
- new Flash('Failed to update tag!', 'alert', document.querySelector('.js-protected-tags-list'));
- },
- }).always(() => {
+ }).then(() => {
+ this.$allowedToCreateDropdownButton.enable();
+ }).catch(() => {
this.$allowedToCreateDropdownButton.enable();
+
+ flash('Failed to update tag!', 'alert', document.querySelector('.js-protected-tags-list'));
});
}
}