Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClement Ho <clemmakesapps@gmail.com>2018-02-08 00:45:03 +0300
committerFatih Acet <acetfatih@gmail.com>2018-02-08 00:45:03 +0300
commit3d4c40a014e045d68ac80b6ebe2a4e498805a261 (patch)
tree1439427392bf2a2ff21cdd3a87445f634f84b697 /app/assets/javascripts/profile
parent071b0ef35ce8e97cbdceb379e3e70a1722badca1 (diff)
Replace $.ajax in profile.js with axios
Diffstat (limited to 'app/assets/javascripts/profile')
-rw-r--r--app/assets/javascripts/profile/profile.js33
1 files changed, 16 insertions, 17 deletions
diff --git a/app/assets/javascripts/profile/profile.js b/app/assets/javascripts/profile/profile.js
index ba4ac850346..e116ee23601 100644
--- a/app/assets/javascripts/profile/profile.js
+++ b/app/assets/javascripts/profile/profile.js
@@ -1,7 +1,9 @@
/* eslint-disable comma-dangle, no-unused-vars, class-methods-use-this, quotes, consistent-return, func-names, prefer-arrow-callback, space-before-function-paren, max-len */
import Cookies from 'js-cookie';
-import Flash from '../flash';
-import { getPagePath } from '../lib/utils/common_utils';
+import { getPagePath } from '~/lib/utils/common_utils';
+import axios from '~/lib/utils/axios_utils';
+import { __ } from '~/locale';
+import flash from '../flash';
((global) => {
class Profile {
@@ -57,8 +59,8 @@ import { getPagePath } from '../lib/utils/common_utils';
onUpdateNotifs(e, data) {
return data.saved ?
- new Flash("Notification settings saved", "notice") :
- new Flash("Failed to save new settings", "alert");
+ flash(__('Notification settings saved'), 'notice') :
+ flash(__('Failed to save new settings'));
}
saveForm() {
@@ -70,21 +72,18 @@ import { getPagePath } from '../lib/utils/common_utils';
formData.append('user[avatar]', avatarBlob, 'avatar.png');
}
- return $.ajax({
+ axios({
+ method: this.form.attr('method'),
url: this.form.attr('action'),
- type: this.form.attr('method'),
data: formData,
- dataType: "json",
- processData: false,
- contentType: false,
- success: response => new Flash(response.message, 'notice'),
- error: jqXHR => new Flash(jqXHR.responseJSON.message, 'alert'),
- complete: () => {
- window.scrollTo(0, 0);
- // Enable submit button after requests ends
- return self.form.find(':input[disabled]').enable();
- }
- });
+ })
+ .then(({ data }) => flash(data.message, 'notice'))
+ .then(() => {
+ window.scrollTo(0, 0);
+ // Enable submit button after requests ends
+ self.form.find(':input[disabled]').enable();
+ })
+ .catch(error => flash(error.message));
}
setNewRepoCookie() {