diff options
author | Phil Hughes <me@iamphill.com> | 2018-01-29 13:00:15 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-01-29 13:00:18 +0000 |
commit | 0c2c8773fbcad9b837500b12f01de754e4bd36a6 (patch) | |
tree | 403ae7c540785cb771128a1d5c6a778574a90dfd /app | |
parent | 5792faf4ae45b3380478bf9abaf9993c711354b3 (diff) | |
download | gitlab-ce-0c2c8773fbcad9b837500b12f01de754e4bd36a6.tar.gz |
Converted integration_settings_form to axios
Diffstat (limited to 'app')
-rw-r--r-- | app/assets/javascripts/integrations/integration_settings_form.js | 48 |
1 files changed, 23 insertions, 25 deletions
diff --git a/app/assets/javascripts/integrations/integration_settings_form.js b/app/assets/javascripts/integrations/integration_settings_form.js index 32415a8791f..3f27cfc2f6d 100644 --- a/app/assets/javascripts/integrations/integration_settings_form.js +++ b/app/assets/javascripts/integrations/integration_settings_form.js @@ -1,4 +1,5 @@ -import Flash from '../flash'; +import axios from '../lib/utils/axios_utils'; +import flash from '../flash'; export default class IntegrationSettingsForm { constructor(formSelector) { @@ -95,29 +96,26 @@ export default class IntegrationSettingsForm { */ testSettings(formData) { this.toggleSubmitBtnState(true); - $.ajax({ - type: 'PUT', - url: this.testEndPoint, - data: formData, - }) - .done((res) => { - if (res.error) { - new Flash(`${res.message} ${res.service_response}`, 'alert', document, { - title: 'Save anyway', - clickHandler: (e) => { - e.preventDefault(); - this.$form.submit(); - }, - }); - } else { - this.$form.submit(); - } - }) - .fail(() => { - new Flash('Something went wrong on our end.'); - }) - .always(() => { - this.toggleSubmitBtnState(false); - }); + + return axios.put(this.testEndPoint, formData) + .then(({ data }) => { + if (data.error) { + flash(`${data.message} ${data.service_response}`, 'alert', document, { + title: 'Save anyway', + clickHandler: (e) => { + e.preventDefault(); + this.$form.submit(); + }, + }); + } else { + this.$form.submit(); + } + + this.toggleSubmitBtnState(false); + }) + .catch(() => { + flash('Something went wrong on our end.'); + this.toggleSubmitBtnState(false); + }); } } |