-
Notifications
You must be signed in to change notification settings - Fork 800
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
Gutenpack: Add/contact form to the gutenberg editor #10537
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for the great PR description! When this PR is ready for review, please apply the Scheduled Jetpack release: November 26, 2018. Generated by 🚫 dangerJS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is ready for review yet, but I had a small question.
@@ -232,6 +232,97 @@ function __construct() { | |||
*/ | |||
wp_register_style( 'grunion.css', GRUNION_PLUGIN_URL . 'css/grunion.css', array(), JETPACK__VERSION ); | |||
wp_style_add_data( 'grunion.css', 'rtl', 'replace' ); | |||
|
|||
if ( function_exists( 'register_block_type' ) ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we use Jetpack_Gutenberg::is_gutenberg_available
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes good call. The plan is to convert things to jetpack_register_block calls which do that check as well.
aca0004
to
2bd59a1
Compare
Caution: This PR has changes that must be merged to WordPress.com |
@georgestephanis Can you elaborate a bit more about the tests that you want to see? |
Given post_content that it renders properly, primarily. |
Also Fixes Automattic/wp-calypso#28521 |
Caution: This PR has changes that must be merged to WordPress.com |
the failing tests seem to be coming from
|
D20923-code. (newly created revision) |
93c213f
to
30deca4
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from some very minor stuff, very happy to clear this.
Thanks for the unit tests, refactoring how we're building the html into more manageable chunks, and the new assertions! It looks super cool!
wrapper.appendChild(menu); | ||
<?php endif; ?> | ||
menu.style.display = 'block'; | ||
var menu = document.getElementById( 'feedback-export' ), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and subsequent lines probably shouldn't be indented with spaces?
@@ -2016,6 +2125,10 @@ static function get_compiled_form( $feedback_id, $form ) { | |||
return $compiled_form; | |||
} | |||
|
|||
static function remove_empty( $single_value ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably could use docblock to explain, but I assume this is here so that we can leave null
false
0
and such that evaluate falsey in the array instead of stripping them out with the ''
?
} | ||
if ( is_array( $val ) ) { | ||
$val = array_filter( $val, array( __CLASS__, 'remove_empty' ) ); | ||
$att_strs[] = esc_html( $att ) . '=\'' . implode( ',', array_map( 'esc_html', $val ) ) . '\''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's kinda awkward to do '\''
all the time -- any reason to not just do "'"
to avoid the escaping?
* Add the gutenberg contact form gutenberg blocks * Gutenpack: Add contact form block * Update form block to use contact-form * Add do_blocks call to the contact render form * Add register_contact_form_blocks block method * Provide default labels * Updates to fix tests the default value of a lable should be null of the type is not set * Minor fixes * Use the jetpack_register_block call to register the contact form blocks Make sure we load them before we load the gutenberg blocks * Bug fix: Only display selections when the option has a value. * Added tests that show what the form doesn't recieve a lavel that we defaul to the default label. * Add tests that shows that we remove empty options when we pass an string containing the empty options * Minor bug fix. Add closing div to the phone field. * Add support for class added in gutenberg * Refactored field Render method so that it is easier to follow. More DRY field render method * Minor fixes * Add unitests for output. * Unit Test fixes so that they work with older version of PHP * Fix: Add more liberal url validaton This removed the validation error when a user doesn't add a http:// or https:// infront of the url. * Improved pattern for the url. * Revert "Improved pattern for the url." This reverts commit 105fcca. * Revert "Fix: Add more liberal url validaton" This reverts commit 0f1a632. * Add support for the defaultValue block attribute * Gutenberg: Conact form ensure we are exposing the contact form's sub-blocks in block availability data. the sub blocks will not be in blocks-manifest.json, so we'll need to ensure we are also including blocks that have been registered internally within jetpack * Fix the tests again :P * Fixes indentation of the js code * Remove comment * Add php doc block for remove_empty * Fixes ugly quotes. * Fix the tests since we are expecting the double quotes now. * With escaped quotes
Cherry-picked to |
It looks like the Fusion-generated counterpart patch (D20308-code) was never merged to WP.com, which is now causing trouble for a PR of mine that seeks to modify |
Oh, looks like D20308-code doesn't contain the changes that this PR made to |
Fixed, thanks to @enejb's D21287-code. |
Fixes #9784
Simplifies the work done by @georgestephanis in #10256
By removing the js code since it should be automatically be included as part of the jetpack blocks.
Now found here Automattic/wp-calypso#27996
Changes proposed in this Pull Request:
Todo:
[ ] Rendering on the front-end (waiting on externals) -
WordPress/gutenberg#11334
Testing instructions:
Proposed changelog entry for your changes:
Add the contact form to the Gutenberg editor.