Commit c840e871 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'axios-members-ajax' into 'master'

Replace $.ajax with axios in members.js

See merge request gitlab-org/gitlab-ee!4473
parents da96cfad 989d4535
import Flash from './flash'; import Flash from './flash';
import { __ } from './locale';
import axios from './lib/utils/axios_utils';
export default class Members { export default class Members {
constructor() { constructor() {
...@@ -50,10 +52,11 @@ export default class Members { ...@@ -50,10 +52,11 @@ export default class Members {
$toggle.disable(); $toggle.disable();
$dateInput.disable(); $dateInput.disable();
this.overrideLdap($memberListItem, $link.data('endpoint'), false).fail(() => { this.overrideLdap($memberListItem, $link.data('endpoint'), false)
$toggle.enable(); .catch(() => {
$dateInput.enable(); $toggle.enable();
}); $dateInput.enable();
});
} }
}, },
}); });
...@@ -101,32 +104,31 @@ export default class Members { ...@@ -101,32 +104,31 @@ export default class Members {
$btn.disable(); $btn.disable();
// eslint-disable-next-line promise/catch-or-return // eslint-disable-next-line promise/catch-or-return
this.overrideLdap($memberListItem, $btn.data('endpoint'), true).then(() => { this.overrideLdap($memberListItem, $btn.data('endpoint'), true)
this.showLDAPPermissionsWarning(e); .then(() => {
this.showLDAPPermissionsWarning(e);
$toggle.enable();
$dateInput.enable(); $toggle.enable();
}).fail((xhr) => { $dateInput.enable();
$btn.enable(); })
.catch((xhr) => {
if (xhr.status === 403) { $btn.enable();
Flash('You do not have the correct permissions to override the settings from the LDAP group sync.', 'alert');
} else { if (xhr.status === 403) {
Flash('An error occured whilst saving LDAP override status. Please try again.', 'alert'); Flash(__('You do not have the correct permissions to override the settings from the LDAP group sync.'));
} } else {
}); Flash(__('An error occurred while saving LDAP override status. Please try again.'));
}
});
} }
// eslint-disable-next-line class-methods-use-this // eslint-disable-next-line class-methods-use-this
overrideLdap($memberListitem, endpoint, override) { overrideLdap($memberListitem, endpoint, override) {
return $.ajax({ return axios.patch(endpoint, {
url: endpoint, group_member: {
type: 'PATCH', override,
data: {
group_member: {
override,
},
}, },
}).then(() => { })
.then(() => {
$memberListitem.toggleClass('is-overriden', override); $memberListitem.toggleClass('is-overriden', override);
}); });
} }
......
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