summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorFatih Acet <acetfatih@gmail.com>2018-02-07 21:03:13 +0000
committerFatih Acet <acetfatih@gmail.com>2018-02-07 21:03:13 +0000
commit625eea7e076420079136ba8b913de5a277c34207 (patch)
treeb959da88a403081e7bb904e1fb255d987dc06138 /app
parentfb89f41721edecc1408ab20d1c0cfe5bb1a00a94 (diff)
parent05076d7d12c2de197224aed9aa52a39ee288908b (diff)
downloadgitlab-ce-625eea7e076420079136ba8b913de5a277c34207.tar.gz
Merge branch 'axios-diff-file-editor' into 'master'
Replace $.get in diff file editor with axios See merge request gitlab-org/gitlab-ce!16896
Diffstat (limited to 'app')
-rw-r--r--app/assets/javascripts/merge_conflicts/components/diff_file_editor.js21
1 files changed, 11 insertions, 10 deletions
diff --git a/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js b/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js
index 93f8f6ee926..2cb238529aa 100644
--- a/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js
+++ b/app/assets/javascripts/merge_conflicts/components/diff_file_editor.js
@@ -2,7 +2,9 @@
/* global ace */
import Vue from 'vue';
-import Flash from '../../flash';
+import axios from '~/lib/utils/axios_utils';
+import flash from '~/flash';
+import { __ } from '~/locale';
((global) => {
global.mergeConflicts = global.mergeConflicts || {};
@@ -49,27 +51,26 @@ import Flash from '../../flash';
loadEditor() {
this.loading = true;
- $.get(this.file.content_path)
- .done((file) => {
+ axios.get(this.file.content_path)
+ .then(({ data }) => {
const content = this.$el.querySelector('pre');
- const fileContent = document.createTextNode(file.content);
+ const fileContent = document.createTextNode(data.content);
content.textContent = fileContent.textContent;
- this.originalContent = file.content;
+ this.originalContent = data.content;
this.fileLoaded = true;
this.editor = ace.edit(content);
this.editor.$blockScrolling = Infinity; // Turn off annoying warning
- this.editor.getSession().setMode(`ace/mode/${file.blob_ace_mode}`);
+ this.editor.getSession().setMode(`ace/mode/${data.blob_ace_mode}`);
this.editor.on('change', () => {
this.saveDiffResolution();
});
this.saveDiffResolution();
+ this.loading = false;
})
- .fail(() => {
- new Flash('Failed to load the file, please try again.');
- })
- .always(() => {
+ .catch(() => {
+ flash(__('An error occurred while loading the file'));
this.loading = false;
});
},