Commit da96cfad authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'axios-mirror-pull' into 'master'

Replace $.getJSON with axios in mirrorPull

See merge request gitlab-org/gitlab-ee!4517
parents e4d49957 a873d20f
...@@ -4,6 +4,8 @@ import axios from '~/lib/utils/axios_utils'; ...@@ -4,6 +4,8 @@ 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';
import { __ } from '../locale';
import axios from '../lib/utils/axios_utils';
export default class MirrorPull { export default class MirrorPull {
constructor(formSelector) { constructor(formSelector) {
...@@ -69,20 +71,20 @@ export default class MirrorPull { ...@@ -69,20 +71,20 @@ export default class MirrorPull {
// Make backOff polling to get data // Make backOff polling to get data
backOff((next, stop) => { backOff((next, stop) => {
$.getJSON(`${projectMirrorSSHEndpoint}?ssh_url=${repositoryUrl}`) axios.get(`${projectMirrorSSHEndpoint}?ssh_url=${repositoryUrl}`)
.done((res, statusText, header) => { .then(({ data, status }) => {
if (header.status === 204) { if (status === 204) {
this.backOffRequestCounter = this.backOffRequestCounter += 1; this.backOffRequestCounter = this.backOffRequestCounter += 1;
if (this.backOffRequestCounter < 3) { if (this.backOffRequestCounter < 3) {
next(); next();
} else {
stop(res);
}
} else { } else {
stop(res); stop(data);
} }
}) } else {
.fail(stop); stop(data);
}
})
.catch(stop);
}) })
.then((res) => { .then((res) => {
$btnLoadSpinner.addClass('hidden'); $btnLoadSpinner.addClass('hidden');
...@@ -92,10 +94,11 @@ export default class MirrorPull { ...@@ -92,10 +94,11 @@ export default class MirrorPull {
this.showSSHInformation(res); this.showSSHInformation(res);
} }
}) })
.catch((res) => { .catch(({ response }) => {
// Show failure message when there's an error and re-enable Detect host keys button // Show failure message when there's an error and re-enable Detect host keys button
const failureMessage = res.responseJSON ? res.responseJSON.message : 'Something went wrong on our end.'; const failureMessage = response.data ? response.data.message : __('An error occurred while detecting host keys');
Flash(failureMessage); // eslint-disable-line Flash(failureMessage); // eslint-disable-line
$btnLoadSpinner.addClass('hidden'); $btnLoadSpinner.addClass('hidden');
this.$btnDetectHostKeys.enable(); this.$btnDetectHostKeys.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