-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Update Image block failed upload visuals (#56937)
* refactor: Rename `useIsConnected` to `useNetworkConnectivity` Attempt to better communicate the Hook intent. * test: Add `useNetworkConnectivity` Hook tests * docs: Document `useNetworkConnectivity` Hook * refactor: Rename `withIsConnected` to `withNetworkConnectivity` * fix: Optimistically presume network connectivity Prior to making the asynchronous request to the host app across the bridge, it is a better UX to presume network connectivity is present rather than displaying network connectivity messages briefly. * test: Create realistic default `requestConnectionStatus` mock * fix: Prevent duplicative offline status indicators Hoist the `OfflineStatus` indicator from the block list to the editor. The block list is leveraged for inner blocks, which means it rendered nested `OfflineStatus` indicators for blocks with inner blocks. Additionally, the `editor` package feels like an appropriate location for the offline detection component. * Add subscribeConnectionStatus to MediaUploadProgress component * Update MediaUploadProgress to use withIsConnected HOC * refactor: Fix HoC name reference This was renamed in a commit onto which this branch was rebased. * refactor: Enable Fast Refresh for Image component Place non-React component exports in a separate module to enable Fast Refresh of the React component. * feat: Update the image offline message Match the latest design comps. * refactor: Avoid unnecessary inconsistency in switch case logic Replace early return with logic mirroring the rest of the switch case statements. While I suppose it could be considered subjective, it is odd and confusing that one of the three cases was structured differently. * refactor: Enable Fast Refresh for Image component Place non-React component exports in a separate module to enable Fast Refresh of the React component. * feat: Revert logic intended to display progress bar when offline I believe this logic erroneously prevented the spinner progress bar from displaying when an image is successfully uploading. I.e., the logic read "if show spinner and online, apply 'progress bar hidden' styles." I imagine this confusion is a result of the previous logic using the `||` pattern to conditionally apply the hidden styles, which is confusing in itself. This logic should likely be implemented by the way the host app communicates the upload state. Implementing this in the JavaScript logic is confusing or misleading, in my opinion. It adds a new, somewhat surprising interpretation of the existing states provided by the host app. * refactor: Remove sizing from offline SVG This allows sizing the icon for different contexts. * feat: Update Image block media upload visuals Update iconography and messaging when offline or or there is a upload error. * feat: Add paused media upload state Relying upon the network connection status alone results in the error message erroneously changing whenever a network connection is re-established. The error message, in fact, is a state communicated from the host app's attempt to upload media. Therefore, this creates a new pause state to represent uploads paused while offline. * feat: Scope the paused upload state to the Image block The planned scope of the project was to improve the upload experience of the Image block, as it is the most frequently used media block type. Support for additional block types could be added at a later time. * feat: Enable paused media uploads for Media and Text block types Because the Media and Text block type relies upon a nested Image block, it makes sense to enable the paused media uploads for a consistent UX. * perf: Avoid unnecessary state updates and callback invocations If the upload state and progress is identical, there should be no reason to invoke callbacks, update component state, or re-render. * Add MEDIA_UPLOAD_STATE_PAUSED to Android DeferredEvent emitter * feat: Add Android paused media upload bridge methods Enables the Android host app to mirror the functionality of iOS. * docs: Add change log entry * feat: Add image upload failure dark mode styles --------- Co-authored-by: David Calhoun <[email protected]>
- Loading branch information
1 parent
e27b306
commit ffa9035
Showing
16 changed files
with
189 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
packages/block-editor/src/components/media-upload-progress/constants.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export const MEDIA_UPLOAD_STATE_IDLE = 0; | ||
export const MEDIA_UPLOAD_STATE_UPLOADING = 1; | ||
export const MEDIA_UPLOAD_STATE_SUCCEEDED = 2; | ||
export const MEDIA_UPLOAD_STATE_FAILED = 3; | ||
export const MEDIA_UPLOAD_STATE_RESET = 4; | ||
export const MEDIA_UPLOAD_STATE_PAUSED = 11; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const IMAGE_DEFAULT_FOCAL_POINT = { x: 0.5, y: 0.5 }; |
Oops, something went wrong.