diff options
author | Constance Okoghenun <cokoghenun@gitlab.com> | 2018-02-08 09:47:31 +0100 |
---|---|---|
committer | Constance Okoghenun <cokoghenun@gitlab.com> | 2018-02-08 09:47:31 +0100 |
commit | 36a301a3c9cbb788860b8c4b020b5095fd3a3363 (patch) | |
tree | 91feb10c1151f5b1801db5d2c03af3664b778cd0 /app/assets/javascripts | |
parent | 6441612614fd5b89c7990010b9ba4734dbfe8ef1 (diff) | |
download | gitlab-ce-36a301a3c9cbb788860b8c4b020b5095fd3a3363.tar.gz |
Replaced use of $.get with axios.get and updated tests
Diffstat (limited to 'app/assets/javascripts')
-rw-r--r-- | app/assets/javascripts/diff.js | 8 | ||||
-rw-r--r-- | app/assets/javascripts/gpg_badges.js | 16 |
2 files changed, 17 insertions, 7 deletions
diff --git a/app/assets/javascripts/diff.js b/app/assets/javascripts/diff.js index a162424b3cf..b26422ab725 100644 --- a/app/assets/javascripts/diff.js +++ b/app/assets/javascripts/diff.js @@ -1,3 +1,6 @@ +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; import { getLocationHash } from './lib/utils/url_utility'; import FilesCommentButton from './files_comment_button'; import SingleFileDiff from './single_file_diff'; @@ -69,7 +72,10 @@ export default class Diff { const view = file.data('view'); const params = { since, to, bottom, offset, unfold, view }; - $.get(link, params, response => $target.parent().replaceWith(response)); + // $.get(link, params, response => $target.parent().replaceWith(response)); + axios.get(link, { params }) + .then(({ data }) => $target.parent().replaceWith(data)) + .catch(() => flash(__('An error occurred while loading diff'))); } openAnchoredDiff(cb) { diff --git a/app/assets/javascripts/gpg_badges.js b/app/assets/javascripts/gpg_badges.js index 7ac9dcd1112..11adf4d2826 100644 --- a/app/assets/javascripts/gpg_badges.js +++ b/app/assets/javascripts/gpg_badges.js @@ -1,3 +1,7 @@ +import axios from '~/lib/utils/axios_utils'; +import flash from '~/flash'; +import { __ } from '~/locale'; + export default class GpgBadges { static fetch() { const badges = $('.js-loading-gpg-badge'); @@ -5,13 +9,13 @@ export default class GpgBadges { badges.html('<i class="fa fa-spinner fa-spin"></i>'); - $.get({ - url: form.data('signatures-path'), - data: form.serialize(), - }).done((response) => { - response.signatures.forEach((signature) => { + const params = form.serialize(); + return axios.get(form.data('signatures-path'), { params }) + .then(({ data }) => { + data.signatures.forEach((signature) => { badges.filter(`[data-commit-sha="${signature.commit_sha}"]`).replaceWith(signature.html); }); - }); + }) + .catch(() => flash(__('An error occurred while loading comm'))); } } |