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