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

Add AMP plugin editor sidebar #5589

Merged
merged 148 commits into from
Dec 30, 2020
Merged

Conversation

johnwatkins0
Copy link
Contributor

@johnwatkins0 johnwatkins0 commented Nov 10, 2020

Summary

Fixes #3821
Fixes #3673

On the editor screen, this moves all info about validation errors into a new editor sidebar.

Screen Shot 2020-12-16 at 1 22 01 PM

  • The sidebar shows for users with dev tools turned on
  • It shows if the WP version is 5.3 or above
  • Error details include key information:

Screen Shot 2020-12-16 at 2 02 05 PM

Note: The newBlockSources PHP class is used to get the plugin or theme name responsible for a block (if the block is registered in PHP). It depends on a filter that was introduced in WP 5.5, though, so in older versions of WP the "Source" line falls back to the registered block name (e.g., contact-form/form) similar to how blocks are currently shown on the URL validation screen. Like this:

Screen Shot 2020-12-16 at 2 26 22 PM

  • The "View details" link shown above goes to the URL validation screen in a new tab, opens the error, and scrolls to it.
  • If any errors are kept, the toolbar icon changes and this notice appears:

Screen Shot 2020-12-16 at 2 24 46 PM

Checklist

  • My pull request is addressing an open issue (please create one otherwise).
  • My code is tested and passes existing tests.
  • My code follows the Engineering Guidelines (updates are often made to the guidelines, check it out periodically).

@johnwatkins0 johnwatkins0 marked this pull request as ready for review November 20, 2020 18:19
@johnwatkins0
Copy link
Contributor Author

This is not ready for review, but I un-Drafted it to trigger the zip build.

@pierlon
Copy link
Contributor

pierlon commented Nov 20, 2020

@johnwatkins0 the "Lint: JS" job is failing so zip builds won't occur.

@github-actions
Copy link
Contributor

github-actions bot commented Nov 24, 2020

Plugin builds for 96c1a96 are ready 🛎️!

@johnwatkins0 johnwatkins0 force-pushed the feature/3821-block-validation-sidebar branch from 9386754 to 28cd8a3 Compare November 24, 2020 04:02
@johnwatkins0
Copy link
Contributor Author

johnwatkins0 commented Dec 28, 2020

  • I wonder if the user will be confused when certain types of block icons are paired with the error icons. For example, I at first was a bit confused when I saw this (there was a JS error in the Custom HTML block):

I think we can handle this better in the follow-up issue to adding filters and updating the design. @jwold is currently working on the visual design for that.

Also, I forsee the orange outline being a potential problem if the theme background were to be of a similar color. For example, when I have the Twenty Twenty-One theme activated with the background color #ba6a50 set I see:

This is indeed problematic, but I'm not sure of the best solution given that the AMP plugin doesn't know what types of styles the theme might be applying to the editor. Similar issues can occur with core styles also. So I think we can probably leave this one alone.

There are 2 blocks outlined in the image above but they are almost impossible to see.

  • I was expecting the AMP toolbar button on the block to open the sidebar to the validation error specific to the block. Would that be possible?

Done in 1d6a0a3

  • When I inserted a Custom HTML block with the following contents and saved the post the editor crashed:
    <?php
    

Fixed in b1a6a11

Copy link
Contributor

@pierlon pierlon left a comment

Choose a reason for hiding this comment

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

This works well so far. The only quirk I found is with the AMP toolbar button, where it can now be used to toggle the error panel in the sidebar. Is that intended? I'd imagine it should only be able to open the error panel.

amp_toolbar_button_click.mp4

@johnwatkins0
Copy link
Contributor Author

The only quirk I found is with the AMP toolbar button, where it can now be used to toggle the error panel in the sidebar. Is that intended?

Yes, I see what you mean. Updated in 29cf878. The button will only open the error, not close it.

Copy link
Contributor

@pierlon pierlon left a comment

Choose a reason for hiding this comment

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

Nicely done! 👌

…821-block-validation-sidebar

* 'develop' of github.com:ampproject/amp-wp: (95 commits)
  Simplify logic to ensure -1 <= limit_per_type <= PHP_INT_MAX
  Ensure amp_url_validation_limit_per_type filter returns int
  Mark URLValidationProvider and ScannableURLProvider as internal
  Guard against empty post ID causing global post to be returned by get_post()
  Make RecurringBackgroundTask::schedule_event() final
  Fix ability for BackgroundTaskDeactivator to unschedule hooks
  Reduce URLValidationCron frequency to daily
  Remove obsolete test assertion
  Make CronBasedBackgroundTask non-Conditional
  Update service name for SavePostValidationEvent and add to PHPSTORM_META
  Add missing $args to wp_next_scheduled() call after 1419ef4
  Switch to google-github-actions/setup-gcloud action
  Only run PHPStan if there is a modified PHP file
  Run composer update
  Ensure alphabetical order for patches in composer.json
  Use PHPStan ignore for 'cannot cast array to int'
  Reorder composer.json fields
  Update param type for phpstan
  Remove obsolete amp_is_canonical() examples
  Reorder composer.json fields
  ...
@westonruter
Copy link
Member

Minor thing: When the AMP plugin sidebar is not pinned, I'm seeing the icon not positioned optimally:

image

@westonruter
Copy link
Member

Fixed in ec509b8:

image

<ErrorTypeIcon type={ type } />
</div>
{ type && (
<div className={ `amp-error__error-type-icon amp-error__error-type-icon--${ type?.replace( /_/g, '-' ) }` }>
Copy link
Member

Choose a reason for hiding this comment

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

Optional chaining is unnecessary here since type && ensures it is defined, no?

Suggested change
<div className={ `amp-error__error-type-icon amp-error__error-type-icon--${ type?.replace( /_/g, '-' ) }` }>
<div className={ `amp-error__error-type-icon amp-error__error-type-icon--${ type.replace( /_/g, '-' ) }` }>

@@ -70,15 +69,14 @@ export function Error( { clientId, status, term_id: termId, ...props } ) {
{ __( 'Select block', 'amp' ) }
</Button>
) }
<a
<ExternalLink
href={ detailsUrl.href }
target="_blank"
Copy link
Member

Choose a reason for hiding this comment

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

Instead of _blank we may want this to be a consistent name like validated-url-post-${ postId } so that each of the View Details links will be routed to the same tab.

@@ -100,10 +99,9 @@ export function Sidebar() {

<p>
{ reviewLink && (
<a href={ reviewLink } className="amp-sidebar__review-link" target="_blank" rel="noreferrer">
<ExternalLink href={ reviewLink } className="amp-sidebar__review-link">
Copy link
Member

Choose a reason for hiding this comment

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WS:UX Work stream for UX/Front-end
Projects
None yet
4 participants