diff --git a/contentcuration/contentcuration/frontend/shared/views/MarkdownEditor/MarkdownEditor/MarkdownEditor.vue b/contentcuration/contentcuration/frontend/shared/views/MarkdownEditor/MarkdownEditor/MarkdownEditor.vue index c5577c2b22..7beeccd254 100644 --- a/contentcuration/contentcuration/frontend/shared/views/MarkdownEditor/MarkdownEditor/MarkdownEditor.vue +++ b/contentcuration/contentcuration/frontend/shared/views/MarkdownEditor/MarkdownEditor/MarkdownEditor.vue @@ -159,6 +159,19 @@ this.initImageFields(); } }, + 'file.error'() { + // eslint-disable-next-line + console.error('The image could not be uploaded'); + }, + 'file.progress'(progress) { + if (progress === 0) { + // eslint-disable-next-line + console.log('The image upload has started'); + } else if (progress === 1) { + // eslint-disable-next-line + console.log('The image upload has finished'); + } + }, 'file.file_on_disk'(src) { if (src) { this.insertImageToEditor({ src, alt: '' }); diff --git a/contentcuration/contentcuration/frontend/shared/vuex/file/actions.js b/contentcuration/contentcuration/frontend/shared/vuex/file/actions.js index c01f3c65e8..c475346259 100644 --- a/contentcuration/contentcuration/frontend/shared/vuex/file/actions.js +++ b/contentcuration/contentcuration/frontend/shared/vuex/file/actions.js @@ -185,6 +185,17 @@ export function uploadFile(context, { file }) { contentType: response.data['mimetype'], }) .then(response => { + // This should ideally not happen when a successful + // response is returned but let's be careful to report + // it appropriately (e.g. we watch "file_on_disk" in our + // components so when an empty response was returned here, + // the file upload failed silently) + if (!response.data) { + context.commit('ADD_FILEUPLOAD', { + checksum, + error: fileErrors.UPLOAD_FAILED, + }); + } context.commit('ADD_FILEUPLOAD', { checksum, file_on_disk: response.data }); }) .catch(() => {