Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@
this.initImageFields();
}
},
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Those two new watchers are related to a situation when a new file is dropped to the editor area (when uploading an image using the image upload menu, progress and errors will be displayed - I haven't checked yet but can see that implementation is there)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up issue #2177

'file.error'() {
// eslint-disable-next-line
console.error('The image could not be uploaded');
Copy link
Contributor

@jayoshih jayoshih Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be a snackbar instead of a console error. Something like "Upload failed. Please try again."

},
'file.progress'(progress) {
if (progress === 0) {
// eslint-disable-next-line
console.log('The image upload has started');
Copy link
Contributor

@jayoshih jayoshih Sep 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably good to remove this later, but makes sense to have it in the short term. Ideally, there would be a progress bar somewhere to show uploading in progress

} 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: '' });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down