Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Editor: Additional error messages for media upload failures #17971

Merged
merged 5 commits into from
Feb 18, 2022

Conversation

SiobhyB
Copy link
Contributor

@SiobhyB SiobhyB commented Feb 16, 2022

Fixes #14400

Description

When an image fails to load via the image block in the editor (for any reason other than there being no Internet connection) a progress indicator currently remains indefinitely on screen. The user will only see an error if they tap on the image (in which case an error appears in the Retry action sheet) or if they save the post as a draft.

Proposed changes

When an upload's thumbnail is ready, we don't currently check whether the upload failed, we only check whether the app is connected to the Internet (as per #14140). That leads to a situation where uploads that fail (for reasons other than no Internet connection) are assigned an "uploading" state via this line of code. This sends a signal back to Gutenberg and prevents an error message for the failure from being displayed correctly.

With this PR, a check for whether an upload failed has been added to guard against that in the thumbnailReady state here. I chose to use media.remoteStatus == .failed for the check as it matches the pattern used in the switch statement here for uploads to the Media Library.

Screenshots

You'll see that, prior to this change, an upload failed "silently", with no error message to indicate that it was not successful. The changes in this PR address that issue so that the error message now displays as expected following the failure:

Before After

Testing

Prerequisite: A WordPress.com Simple site with a media library that's been filled up to the site's storage limit. The credentials for an existing test site that matches that criteria be found here: paaHJt-17e-p2#comment-2395

Steps to test:

  1. Start a new post.
  2. Add an image block.
  3. Select an image to upload.
  4. Desired result: The image placeholder appears with an error message.
  5. Prior to this change: The error message did not display, instead there was a permanent placeholder/progress indicator.

Regression Notes

  1. Potential unintended areas of impact

The code area that's been tweaked with this change relates to the way an image's thumbnail appears when it's uploaded in the editor. It may therefore unintentionally impact the way the thumbnail appears.

  1. What I did to test those areas of impact (or what existing automated tests I relied on)

Manually tested uploading an image to ensure the thumbnail displays as expected, both when the upload fails and when it's successful.

  1. What automated tests I added (or what prevented me from doing so)

No automated tests have been added as this is a relatively small fix for the UI, I didn't feel an automated test was necessary.


PR submission checklist:

  • I have completed the Regression Notes.
  • I have considered adding unit tests for my changes.
  • I have considered adding accessibility improvements for my changes.
  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

When an upload's thumbnail is ready, we don't currently check whether the upload actually failed. That leads to a situation where failed uploads are assigned an "uploading" state, which prevents Gutenberg from getting the necessary signals to display an error message for the failure.

With this commit, a check for whether an upload failed is added to prevent this issue.
@SiobhyB SiobhyB added Gutenberg Editing and display of Gutenberg blocks. Media Posting/Editing labels Feb 16, 2022
@SiobhyB SiobhyB changed the title Editor: Prevent "missing" error messages when media failures Editor: Prevent "missing" error messages with media upload failures Feb 17, 2022
@SiobhyB SiobhyB added this to the 19.3 milestone Feb 17, 2022
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 17, 2022

You can test the WordPress changes on this Pull Request by downloading it from AppCenter here with build number: pr17971-3ebc362. IPA is available here. If you need access to this, you can ask a maintainer to add you.

@SiobhyB SiobhyB force-pushed the gutenberg/fix/missing-media-upload-error branch from 6af98a4 to 6f60580 Compare February 17, 2022 17:15
This code is redundant as it is duplicative of code surrounding it, it was mistakenly kept in the first commit.
@SiobhyB SiobhyB marked this pull request as ready for review February 17, 2022 17:19
@wpmobilebot
Copy link
Contributor

wpmobilebot commented Feb 17, 2022

You can test the Jetpack changes on this Pull Request by downloading it from AppCenter here with build number: pr17971-3ebc362. IPA is available here. If you need access to this, you can ask a maintainer to add you.

@SiobhyB SiobhyB requested review from jhnstn and mchowning February 17, 2022 17:59
@mchowning mchowning self-assigned this Feb 17, 2022
Copy link
Contributor

@mchowning mchowning left a comment

Choose a reason for hiding this comment

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

Code looks good and this works well. Such a huge improvement to the UX! 🙌 🥇

@@ -5,6 +5,7 @@
* [*] Add "Copy Link" functionality to Posts List and Pages List [#17911]
* [*] [Jetpack-only] Enables the ability to use and create WordPress.com sites, and enables the Reader tab. [#17914, #17948]
* [*] Block editor: Autocorrected Headings no longer apply bold formatting if they weren't already bold. [#17844]
* [*] Block editor: Prevent "missing" error messages with media upload failures. [#17971]
Copy link
Contributor

Choose a reason for hiding this comment

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

Not a big deal, but the quoted "missing" reads a bit oddly to me (why is missing in quotes? are they not really missing?). I might try phrasing this positively with something like "Additional error messages for media upload failures".

What you have now is fine, so this is definitely not a blocker. Feel free to leave as-is if you prefer.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I appreciate that feedback, thank you! Updated the note in 3ebc362.

@SiobhyB SiobhyB changed the title Editor: Prevent "missing" error messages with media upload failures Editor: Additional error messages for media upload failures Feb 18, 2022
@peril-wordpress-mobile
Copy link

Warnings
⚠️ This PR is assigned to a milestone which is closing in less than 4 days Please, make sure to get it merged by then or assign it to a later expiring milestone

Generated by 🚫 dangerJS

@SiobhyB SiobhyB enabled auto-merge February 18, 2022 11:31
@SiobhyB SiobhyB merged commit 9e125f0 into trunk Feb 18, 2022
@SiobhyB SiobhyB deleted the gutenberg/fix/missing-media-upload-error branch February 18, 2022 11:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Gutenberg Editing and display of Gutenberg blocks. Media Posting/Editing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Editor: Media uploads fail silently when site storage is full
3 participants