-
Notifications
You must be signed in to change notification settings - Fork 382
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 validation checking for Gutenberg blocks #1019
Commits on Mar 14, 2018
-
Add source comments around each Gutenberg block to track validation i…
…ssues Remove requirement that amp_debug query var have a value
Configuration menu - View commit details
-
Copy full SHA for 8413457 - Browse repository at this point
Copy the full SHA 8413457View commit details -
Defer mustache tag replacements to right before serialization and onl…
…y target template elements
Configuration menu - View commit details
-
Copy full SHA for 07aeee2 - Browse repository at this point
Copy the full SHA 07aeee2View commit details
Commits on Mar 17, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 01691e5 - Browse repository at this point
Copy the full SHA 01691e5View commit details
Commits on Mar 18, 2018
-
Revert commit that removed REST API logic.
Commit ba9365 removed this, as it wasn't needed for 0.7. This restores the logic for the REST API, but not the wp-cron logic. See PR #971.
Ryan Kienstra committedMar 18, 2018 Configuration menu - View commit details
-
Copy full SHA for 27e8bec - Browse repository at this point
Copy the full SHA 27e8becView commit details -
Prototype asynchronous notices for blocks.
The POST to the REST API in the JS file doesn't work yet. And this doesn't apply a requirement in PR #1019: 'Pass validation errors back in REST API response when Gutenberg saves a post.' But this is a prototype of a way to display notices for each block, async. The UX would be like that in the previous PR #902. As Weston mentioned earlier, edit() is synchronous. And REST requests to validate content could delay it. So add a component for 'edit.' Display a notice, based on the state of isValidAMP. The REST API request will update the state.
Ryan Kienstra committedMar 18, 2018 Configuration menu - View commit details
-
Copy full SHA for 590cd76 - Browse repository at this point
Copy the full SHA 590cd76View commit details
Commits on Mar 19, 2018
-
Rever commit 27e8b, which added REST API endpoint.
The approach changed, and I'm going to add a response field to existing endpoints.
Ryan Kienstra committedMar 19, 2018 Configuration menu - View commit details
-
Copy full SHA for 8218919 - Browse repository at this point
Copy the full SHA 8218919View commit details -
Add amp_validation field to REST API response.
@todo: implement the output callback. Thanks to Weston's suggestion, This will enable displaying notices in blocks.
Ryan Kienstra committedMar 19, 2018 Configuration menu - View commit details
-
Copy full SHA for 9c3568d - Browse repository at this point
Copy the full SHA 9c3568dView commit details -
Output validation errors in REST API response.
In new field 'amp_validation_errors'. @todo: we might not always want to output this. It's mainly useful in the Gutenberg editor.
Ryan Kienstra committedMar 19, 2018 Configuration menu - View commit details
-
Copy full SHA for ab82e8d - Browse repository at this point
Copy the full SHA ab82e8dView commit details
Commits on Mar 20, 2018
-
Remove jQuery dependency and ES6 class.
As Weston mentioned, we can't use ES6 classes in IE11. The script is probably going to change drastically, in how it displays notices for validation errors. So remove almost all of the existing logic.
Ryan Kienstra committedMar 20, 2018 Configuration menu - View commit details
-
Copy full SHA for ea1c37a - Browse repository at this point
Copy the full SHA ea1c37aView commit details -
Change which post types have the added field.
Per Weston's suggestion, if this is Native AMP (canonical), it will be all posts with 'editor' support. Otherwise, all REST objects that have 'amp' support.
Ryan Kienstra committedMar 20, 2018 Configuration menu - View commit details
-
Copy full SHA for 96297fc - Browse repository at this point
Copy the full SHA 96297fcView commit details
Commits on Mar 21, 2018
-
In REST API response, validate front-end if no errors exist.
Abstract existing logic into: get_existing_validation_errors(). And reuse this for rest_field_amp_validation(). If this doesn't return errors, make a request to the front-end for them.
Ryan Kienstra committedMar 21, 2018 Configuration menu - View commit details
-
Copy full SHA for ed4b03b - Browse repository at this point
Copy the full SHA ed4b03bView commit details -
Skip Gutenberg-based tests for WP version < 4.9.
Gutenberg doesn't init if the version is below this. This addresses a failed Travis build.
Ryan Kienstra committedMar 21, 2018 Configuration menu - View commit details
-
Copy full SHA for 561af32 - Browse repository at this point
Copy the full SHA 561af32View commit details -
Begin to add notices to blocks based on errors.
So far, this only finds if there is an error somewhere. And it displays a notice below the block. But it has access to the errors by block name, though not the specific ID of the block.
Ryan Kienstra committedMar 21, 2018 Configuration menu - View commit details
-
Copy full SHA for f64ab2e - Browse repository at this point
Copy the full SHA f64ab2eView commit details -
Address Travis error by aligning array values vertically.
Ryan Kienstra committedMar 21, 2018 Configuration menu - View commit details
-
Copy full SHA for b9bd206 - Browse repository at this point
Copy the full SHA b9bd206View commit details
Commits on Mar 22, 2018
-
Get the block types with errors from the REST API response.
The response can have a 'block_name' value. When it does, store that specific block's errors, This enables lookup by the block name in the edit() method of the block. @todo: consider keeping this in a store. And find the specific block to which they belong. Not only the block name.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for bcdff5f - Browse repository at this point
Copy the full SHA bcdff5fView commit details -
Update test to reflect change in text.
To address a failed Travis build. Also, change the text, so that it can apply to singular an plural. 'invalid AMP' instead of 'AMP errors.'
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for 049e482 - Browse repository at this point
Copy the full SHA 049e482View commit details -
Store the block validation errors, avoiding lookup in every edit().
Before, this got the block errors from getCurrentPost(), in every block's edit() method. Instead, store these in the module, every time there is an action. It would be better to use a reducer for a specific action. But so far, I haven't found a way to do that for REQUEST_POST_UPDATE_SUCCESS.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for fe34e8e - Browse repository at this point
Copy the full SHA fe34e8eView commit details -
Get validation errors for specific blocks, not only for block names.
module.blocksWithErrors stores errors by block name. In the block edit() method, it needs to find if it has the specific errors. So find if the errors exist in the content by searching it for the node_name, and the attributes and properties. @todo: account for other errors, like enqueued scripts.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for 49b66ae - Browse repository at this point
Copy the full SHA 49b66aeView commit details -
Address Travis errors by raising variable declaration.
This is now at the top of the function scope. Also, move 2 nested if blocks into 1 block.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for 743cca4 - Browse repository at this point
Copy the full SHA 743cca4View commit details -
Add 'block_attrs' to blocksWithErrors.
As Weston mentioned, they will be useful in matching the specific block to the errors. This will make it much easier to access them.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for 4676777 - Browse repository at this point
Copy the full SHA 4676777View commit details -
Correct the variable for block_attrs.
This was actually in source, not blocksWithErrors. So change it to source.
Ryan Kienstra committedMar 22, 2018 Configuration menu - View commit details
-
Copy full SHA for b9aa16c - Browse repository at this point
Copy the full SHA b9aa16cView commit details
Commits on Mar 23, 2018
-
Use the new blockAttrs to find a match with errors.
This can match blocks that add a stripped script. Like the 'Categories' block. That wasn't part of the content, so it wasn't found before. Also, refactor existing logic into: doNameAndAttributesMatch(). This is better in a function, as it uses a for loop to return a value. Otherwise, it would need to set a flag.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for e2fc9a7 - Browse repository at this point
Copy the full SHA e2fc9a7View commit details -
Move the notice from below to above the block.
This follows the convention in WP. And update the notice text for this. It was below the block before, as the edit() function sometimes found errors quickly. And this moved the block lower, as the notice took the space of the block.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for 6cd996a - Browse repository at this point
Copy the full SHA 6cd996aView commit details -
Add a 'More details' link to the notice.
This links to the post.php page with the errors. Use the component ExternalLink.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for 339f69f - Browse repository at this point
Copy the full SHA 339f69fView commit details -
Enable showing multiple validation errors.
For example: This core/html block has invalid AMP: invalid_attribute, invalid_element. @todo: consider having counts for each, like in the classic editor notice.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for a02d029 - Browse repository at this point
Copy the full SHA a02d029View commit details -
Enable outputting several error codes, and their counts.
Mainly uses Weston's work from: AMP_Validation_Utils::output_removed_set(). @todo: address an case where multiple blocks have the same error. Their count is then higher than it should be.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for 15f0abe - Browse repository at this point
Copy the full SHA 15f0abeView commit details -
Address a Travis error regarding complexity.
'doNameAndAttributesMatch' has a complexity of 9. So refactor part of it into: getAttributesKey().
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for 2b03c6a - Browse repository at this point
Copy the full SHA 2b03c6aView commit details -
Remove the counts from after the error codes.
There were duplicate counts when blocks has the same errors. For example, if 2 HTML blocks have 'onclick' attributes. Of if there are 2 Categories blocks with a dropdown.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for d366da3 - Browse repository at this point
Copy the full SHA d366da3View commit details -
Add keys to the components and edit block.
It seems like each of these should have different keys. And other examples of this in Gutenberg have keys.
Ryan Kienstra committedMar 23, 2018 Configuration menu - View commit details
-
Copy full SHA for 80d32de - Browse repository at this point
Copy the full SHA 80d32deView commit details
Commits on Mar 26, 2018
-
Ryan Kienstra committed
Mar 26, 2018 Configuration menu - View commit details
-
Copy full SHA for 16388c2 - Browse repository at this point
Copy the full SHA 16388c2View commit details
Commits on Apr 6, 2018
-
Merge in develop, resolve conflicts.
There were 2 trivial conflicts: class-amp-validation-utils.php test-class-amp-validation-utils.php Also, there was a failed test in: test_enqueue_block_validation. So I removed the : from 'This %s block has invalid AMP'.
Configuration menu - View commit details
-
Copy full SHA for f9d8575 - Browse repository at this point
Copy the full SHA f9d8575View commit details -
Address Travis error by removing extra comma.
There was a comma after the argument for: result.unshift().
Configuration menu - View commit details
-
Copy full SHA for 9aa6704 - Browse repository at this point
Copy the full SHA 9aa6704View commit details
Commits on Apr 8, 2018
-
Force re-validation of post on frontend for amp_validation_errors fie…
…ld in POST/PUT requests Tidy jsdoc
Configuration menu - View commit details
-
Copy full SHA for dcb1e77 - Browse repository at this point
Copy the full SHA dcb1e77View commit details -
Configuration menu - View commit details
-
Copy full SHA for eb00bcf - Browse repository at this point
Copy the full SHA eb00bcfView commit details -
Configuration menu - View commit details
-
Copy full SHA for 9ecc24c - Browse repository at this point
Copy the full SHA 9ecc24cView commit details -
Remove block error summary while waiting for design to formulate
* Fix population of notice children. * Show simple list of error codes for now. * Remove PHP-exporting of validation status post since needs to be dynamic REST field. * Replace extraneous hasOwnProperty with simply key existence checks (since object literals). * Add some todos.
Configuration menu - View commit details
-
Copy full SHA for 354fdcd - Browse repository at this point
Copy the full SHA 354fdcdView commit details
Commits on Apr 9, 2018
-
Fix delay between save and update of validation error notice
Stop iterating sources for validation error once inner-most block is matched
Configuration menu - View commit details
-
Copy full SHA for 0bada73 - Browse repository at this point
Copy the full SHA 0bada73View commit details -
Configuration menu - View commit details
-
Copy full SHA for 34024cc - Browse repository at this point
Copy the full SHA 34024ccView commit details -
Prevent reporting validation errors for blocks that are not in the cu…
…rrent post * Include post_id and block_content_index in block sources. * Prevent reporting validation errors for blocks that are not in the current post. * Include block_content_index for improved alignment between blocks and validation errors.
Configuration menu - View commit details
-
Copy full SHA for 8e78904 - Browse repository at this point
Copy the full SHA 8e78904View commit details
Commits on Apr 10, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 277da63 - Browse repository at this point
Copy the full SHA 277da63View commit details -
Use block content index to match blocks with corresponding validation…
… errors * Use custom store for block validation errors * Connect extended BlockEdit to block validation errors via withSelect HOC.
Configuration menu - View commit details
-
Copy full SHA for ca3ff60 - Browse repository at this point
Copy the full SHA ca3ff60View commit details -
Only update block validation errors when editor state is clean
This helps ensures that the validation errors in the response will properly align with the ordered blocks in the editor.
Configuration menu - View commit details
-
Copy full SHA for 01a21a8 - Browse repository at this point
Copy the full SHA 01a21a8View commit details
Commits on Apr 11, 2018
-
Configuration menu - View commit details
-
Copy full SHA for 3e032d4 - Browse repository at this point
Copy the full SHA 3e032d4View commit details -
Configuration menu - View commit details
-
Copy full SHA for 6a4cbcc - Browse repository at this point
Copy the full SHA 6a4cbccView commit details -
Configuration menu - View commit details
-
Copy full SHA for 4d7dc19 - Browse repository at this point
Copy the full SHA 4d7dc19View commit details -
Configuration menu - View commit details
-
Copy full SHA for 21e60f0 - Browse repository at this point
Copy the full SHA 21e60f0View commit details
Commits on Apr 12, 2018
-
Configuration menu - View commit details
-
Copy full SHA for ca6c96c - Browse repository at this point
Copy the full SHA ca6c96cView commit details -
Configuration menu - View commit details
-
Copy full SHA for 7a60509 - Browse repository at this point
Copy the full SHA 7a60509View commit details
Commits on Apr 13, 2018
-
Merge branch 'develop' of https://github.com/Automattic/amp-wp into a…
…dd/block-validation
Configuration menu - View commit details
-
Copy full SHA for 5bf12da - Browse repository at this point
Copy the full SHA 5bf12daView commit details