Commit 989d4535 authored by Clement Ho's avatar Clement Ho Committed by Jacob Schatz

Replace $.ajax with axios in members.js

parent da96cfad
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,7 +52,8 @@ export default class Members { ...@@ -50,7 +52,8 @@ 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)
.catch(() => {
$toggle.enable(); $toggle.enable();
$dateInput.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)
.then(() => {
this.showLDAPPermissionsWarning(e); this.showLDAPPermissionsWarning(e);
$toggle.enable(); $toggle.enable();
$dateInput.enable(); $dateInput.enable();
}).fail((xhr) => { })
.catch((xhr) => {
$btn.enable(); $btn.enable();
if (xhr.status === 403) { if (xhr.status === 403) {
Flash('You do not have the correct permissions to override the settings from the LDAP group sync.', 'alert'); Flash(__('You do not have the correct permissions to override the settings from the LDAP group sync.'));
} else { } else {
Flash('An error occured whilst saving LDAP override status. Please try again.', 'alert'); 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,
type: 'PATCH',
data: {
group_member: { group_member: {
override, 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