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

Block Directory: Try/block directory inline error msgs. #19589

Conversation

StevenDufresne
Copy link
Contributor

Description

This PR is an experiment to add inline error messages to the block directory. This PR also introduces a change in execution that needs discussion.

Background Info

  • We currently, download the assets (which means we inject scripts into the DOM)
  • Then we install the assets by calling an API rest endpoint (.... the plugin ends up in their plugins folder)
  • We currently execute download then install as a callback.
  • During the download sequence, the block is registered which closes the menu (because the way the inserter works) and then the install is executed with the menu closed. Should any issues arise, the error message will appear with a bit of a delay.
  • If the block fails at install we offer them a button and allow them to remove the block.
    • If they don't remove and reload the page, the block is broken. There is no way to fix it.

Types of changes

Changes:

Along with the obvious changes to add errors inline, this PR changes the order of execution. Instead of immediate injecting the assets in the download sequence and then installing. This PR first installs and then downloads.

Why?

  • Before this PR, the inserter disappears as soon as the block gets registered in the download phase (the block registers and update the state). This means that if an error is throw on install, the context has already changed. We can't show anything inline, it's gone.
  • If a block fails at install there isn't much recourse to fix it. Now, or potentially in the future. This means we have a broken plugin in the document. We therefore would need to have a robust "removal" experience. By flipping it, nothing is added until everything is :100 with the server.
  • We could maintain a thinner front end package since the error logic and validation stays on the server and does creep to the front end.

Cons

  • There is a delay as we install (subject to the network speed)
    • Added a loading state to the button to mitigate.
  • ... probably more

Known Issues

  • We should consider a better way to close the inserter. There is a callback that is passed in from the inserter slot onSelect, but it has a lower priority and depending on the state of the app, you could see a bit of a flicker. I have seen it sporadically.

Screenshots

Before After
Success Before Success After Success
Install Error Before Install Error Disregard that the component actually was loaded below. After Install Error
Download Error Before Download Error After Download Error Mimicking this issue was tough and therefore I couldn't resolve the "Retry" work... but it is retrying :).

How has this been tested?

  • Unit tests were added to cover the changes

Manual Testing

Manual test were done by doing the following: ( using these block: Card, Boxer, Listicle)

Case Success

  1. Search/Add Block
    a. Notice that the block is added to the document without error
    b. Notice that the plugin is not in the regular WordPress plugin folder

Case Install Error:

  1. Search/Add a block
    a. Make the /install endpoint return an error on first call
    b. Notice the error message is showing with the proper copy..
  2. Click Retry
    a. Notice the error message is removed
    b. Notice the plugin is in WordPress plugin folder

Case Download Error:

  1. Search/Add a block
    a. Add a throw statement in the download function in action.js to mimick and issue with adding assets to the DOM
    b. Notice the error message is showing with the proper copy.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

@StevenDufresne StevenDufresne marked this pull request as ready for review January 13, 2020 06:50
@StevenDufresne StevenDufresne changed the title Try/block directory inline error msgs Block Directory: Try/block directory inline error msgs. Jan 13, 2020
sirreal and others added 19 commits January 13, 2020 09:29
* Declare sideEffects for build-style

* fixup! Declare sideEffects for build-style

* Add CHANGELOG entries
* RNMobile - Refactor of Caption component into two: BlockCaption and Caption component

* RNMobile - Refactor of Caption component

* RNMobile - Caption refactor passing accessibility props and adding missing accessibility label for the Video block's caption

* RNMobile - Caption: Specify p tag for both platforms
* Return focus to original element

* Fix list e2e tests

* Fix annotation e2e tests

* Fix some rich text e2e tests

* Fix tests

* Focus after link

* Add onFocus

* Corrections
* wip

* Wait for block to mount

* Fix some tests

* Revert moving focus effects

* Fix align error

* Fix navigation mode

* Fix capturing toolbar

* Remove has-toolbar-captured

* Add docs

* Simplify multi selection selector

* Fix alignment

* Clean up

* Only add block node for selected block

* Simplify block DOM node state

* Fix alignment tests

* Clean up

* Clean up

* Avoid node in state
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
 - @wordpress/[email protected]
…ordPress#19528)

* adds no title label to links to pages or posts with no title

* fixes a wrong return and an explicit comparison

* undo mistaken CSS edit
* Block: reposition tabbable inserter

* Fix e2e
* Block Library: Add a Post Excerpt block.

* Block Library: Make Post Excerpt block editable.

* E2E Tests: Add Post Excerpt block fixtures.
* Components: Add isFocusable state to Button

* Make isFocusable true by default

* Update styles

* Remove stopImmediatePropagation call

* Fix unit tests

* Fix e2e tests

* Make isFocusable prop experimental and false by default
* Improved style of image block placeholder during upload

* Improved style of VIDEO  block placeholder during upload

* Removing unreachable code.

* Removed redundant style props
* adds media replace flow to the cover block

* adds video suppor to upload in media replace control
* Block: try merging effects

* Merge multi selected effect
@StevenDufresne
Copy link
Contributor Author

Ah dang, this went poorly. I'm going to close and reopen.

@StevenDufresne
Copy link
Contributor Author

Reopened here: #20001

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Block Directory Related to the Block Directory, a repository of block plugins Needs Design Feedback Needs general design feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.