diff options
author | Phil Hughes <me@iamphill.com> | 2018-01-26 10:34:22 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2018-01-29 09:06:57 +0000 |
commit | e63882e8b9074140b89a4a5f7dc39adf8a0b0324 (patch) | |
tree | ba83be2e815967d9da58a5e29cf97d4d5b9e8d07 | |
parent | 6a89ce29533d43aa7c34fb2a5e54b9ff4048e73b (diff) | |
download | gitlab-ce-e63882e8b9074140b89a4a5f7dc39adf8a0b0324.tar.gz |
Converted dropzone_input to axios
-rw-r--r-- | app/assets/javascripts/dropzone_input.js | 33 |
1 files changed, 15 insertions, 18 deletions
diff --git a/app/assets/javascripts/dropzone_input.js b/app/assets/javascripts/dropzone_input.js index 550dbdda922..ba89e5726fa 100644 --- a/app/assets/javascripts/dropzone_input.js +++ b/app/assets/javascripts/dropzone_input.js @@ -2,6 +2,7 @@ import Dropzone from 'dropzone'; import _ from 'underscore'; import './preview_markdown'; import csrf from './lib/utils/csrf'; +import axios from './lib/utils/axios_utils'; Dropzone.autoDiscover = false; @@ -235,25 +236,21 @@ export default function dropzoneInput(form) { uploadFile = (item, filename) => { const formData = new FormData(); formData.append('file', item, filename); - return $.ajax({ - url: uploadsPath, - type: 'POST', - data: formData, - dataType: 'json', - processData: false, - contentType: false, - headers: csrf.headers, - beforeSend: () => { - showSpinner(); - return closeAlertMessage(); - }, - success: (e, text, response) => { - const md = response.responseJSON.link.markdown; + + showSpinner(); + closeAlertMessage(); + + axios.post(uploadsPath, formData) + .then(({ data }) => { + const md = data.link.markdown; + insertToTextArea(filename, md); - }, - error: response => showError(response.responseJSON.message), - complete: () => closeSpinner(), - }); + closeSpinner(); + }) + .catch((e) => { + showError(e.response.data.message); + closeSpinner(); + }); }; updateAttachingMessage = (files, messageContainer) => { |