Commit a761d201 authored by Clement Ho's avatar Clement Ho Committed by Jacob Schatz

Replace $.ajax with axios in mirror pull

parent 4ca5b238
import _ from 'underscore'; import _ from 'underscore';
import { __ } from '~/locale';
import axios from '~/lib/utils/axios_utils';
import Flash from '../flash'; import Flash from '../flash';
import AUTH_METHOD from './constants'; import AUTH_METHOD from './constants';
import { backOff } from '../lib/utils/common_utils'; import { backOff } from '../lib/utils/common_utils';
...@@ -145,22 +147,24 @@ export default class MirrorPull { ...@@ -145,22 +147,24 @@ export default class MirrorPull {
if (selectedAuthType === AUTH_METHOD.SSH && if (selectedAuthType === AUTH_METHOD.SSH &&
!$sshPublicKey.text().trim()) { !$sshPublicKey.text().trim()) {
this.$dropdownAuthType.disable(); this.$dropdownAuthType.disable();
$.ajax({
type: 'PUT', axios.put(projectMirrorAuthTypeEndpoint, JSON.stringify(authTypeData), {
url: projectMirrorAuthTypeEndpoint, headers: {
contentType: 'application/json; charset=utf-8', 'Content-Type': 'application/json; charset=utf-8',
data: JSON.stringify(authTypeData), },
}) })
.done((res) => { .then(({ data }) => {
// Show SSH public key container and fill in public key // Show SSH public key container and fill in public key
this.toggleAuthWell(selectedAuthType); this.toggleAuthWell(selectedAuthType);
this.toggleSSHAuthWellMessage(true); this.toggleSSHAuthWellMessage(true);
this.setSSHPublicKey(res.import_data_attributes.ssh_public_key); this.setSSHPublicKey(data.import_data_attributes.ssh_public_key);
})
.fail(() => { this.$wellAuthTypeChanging.addClass('hidden');
Flash('Something went wrong on our end.'); this.$dropdownAuthType.enable();
}) })
.always(() => { .catch(() => {
Flash(__('Something went wrong on our end.'));
this.$wellAuthTypeChanging.addClass('hidden'); this.$wellAuthTypeChanging.addClass('hidden');
this.$dropdownAuthType.enable(); this.$dropdownAuthType.enable();
}); });
......
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