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

Revue Block #14645

Merged
merged 25 commits into from
Feb 24, 2020
Merged

Revue Block #14645

merged 25 commits into from
Feb 24, 2020

Conversation

Copons
Copy link
Contributor

@Copons Copons commented Feb 11, 2020

Changes proposed in this Pull Request:

  • Add a new Revue block.

For this simple implementation we have decided to not use the Revue API, but simply show a subscription form, linked to a Revue user through its username, that on submit opens Revue in a new tab.

Editor Front End
Screenshot 2020-02-19 at 16 02 35 Screenshot 2020-02-19 at 16 03 14

Notes

  • I've decided to reimplement (yet again) the submit button logic, copying it from the latest Gutenberg version (as of last week) that also has gradient backgrounds available, instead of using our own SubmitButton.
    This is mostly to be as consistent as possible to Core Gutenberg, both on the edit side and on the SSR.
    I recognize this is definitely not ideal, and I'd rather use a single button implementation that was as similar to Core Gutenberg's Button block.
    @pablinos (since you're working on it) do you think the work in this PR could be a good starting point for a SubmitButton update?

  • Form styles aren't typically exposed by the theme to the editor to avoid conflicts with the editor styles. For this reason, the design is slightly different between editor and front end.
    I don't have a good solution for this off the top of my head, but maybe I'm missing something. 🤔

  • Since the submit opens a new tab, going back to the post and seeing the form as nothing happened felt a bit awkward to me.
    Currently, 1 second after the submission, when the user is supposedly on the Revue page, the form is replaced by a "You can complete your registration in the new page." message.
    This message is not permanent, and it's enough to reload the post to see the form again.
    I'm not sold on the copy or the look, and I guess we could embellish them in several ways.
    What do you think? (cc @davemart-in)

Is this a new feature or does it add/remove features to an existing part of Jetpack?

  • pb5gDS-jZ-p2

Testing instructions:

  • Create an account on Revue.
  • Open the editor and insert a Revue block.
  • Enter your Revue username.
  • Try customizing the submit button.
  • Save and view the post.
  • Make sure the button show up with the same customizations in the front end.
  • Fill the form with an email address (not the same as the Revue account).
  • On submit you should open a Revue page with the next steps instructions.
  • Check your email for a Revue email to confirm that the subscription happened (whatever happens next is in their hands).

Proposed changelog entry for your changes:

  • Add a new Revue block.

@jetpackbot
Copy link

jetpackbot commented Feb 11, 2020

Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

Generated by 🚫 dangerJS against b9aa5a0

@jeherve jeherve added [Block] Revue [Type] Feature Request [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Feb 11, 2020
@Copons Copons requested a review from a team February 19, 2020 16:13
@Copons Copons added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] In Progress labels Feb 19, 2020
@Copons Copons changed the title [WIP] Revue Block Revue Block Feb 19, 2020
@scruffian
Copy link
Member

This block looks very similar to our Jetpack Contact Form block. Is there any way we could reuse some of that here?

@scruffian
Copy link
Member

For the button, is there any reason we can't use the core button block as a child block?

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello Copons! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer, review, and approve D39155-code before merging this PR. Thank you!

@Copons
Copy link
Contributor Author

Copons commented Feb 20, 2020

This block looks very similar to our Jetpack Contact Form block. Is there any way we could reuse some of that here?

@scruffian It occurred to me as well, but then in this case we don't really want for the user to customize the form at all.

  • The email field is required (I'd have to double check if Revue also expects a member[subscribe] property from the submit button).
  • The fields need to have a precise name (e.g. member[email]).
  • JPCF lets user change the input names but only by assigning an ID to them, which is not great if we want to have multiple Revue subscription blocks in the same page.

This said, I've tried to keep the two as visually consistent as possible in the front end.

For the button, is there any reason we can't use the core button block as a child block?

Admittedly I haven't tried, but off the top of my head, the Button block outputs an anchor element, which AFAIK can't be used to submit a form without unnecessarily involving JS.

Also, even if Button saved as button or input type="submit", it would be stripped away by WPCOM's KSES on post save.
I haven't tested it yet, but server-side-rendering it straight when the post is displayed should avoid it.

@davemart-in
Copy link
Contributor

davemart-in commented Feb 21, 2020

Thanks @Copons! Here are some thoughts after my review:

  • Can we update the block icon to use this SVG?
  • In the blank slate let's add a link under the username field that says "Need help finding your Revue username?" which will link to the support doc.
  • In the sidebar, let's change the description from "Add a Revue signup form." to "Add a subscription form for your Revue newsletter."
  • The blank slate input and submit button are not vertically aligned. Can we update these to match how we've done it on the Calendly block?
  • Can we update the blank slate button text from "Insert" to "Add Form"?
  • Since first and last name are optional, can we show toggles for them in the sidebar?
  • I'm not entirely sure what the bold, italic, and rich text controls are meant to apply to. Clicking them doesn't seem to do anything. Can we remove them?
  • "Edit as HTML" in the toolbar dropdown produces this. Do we want to just hide that option?
  • Let's change the on submission text from "You can complete your registration in the new page." to Subscription received!
    Please check your email to confirm your newsletter subscription.

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 21, 2020
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Feb 24, 2020
@davemart-in
Copy link
Contributor

davemart-in commented Feb 24, 2020

The form's behaviour in the editor (with the "Preview only" placeholder) is very different from what we're used to with other form blocks. I expected to be able to click around in the form while in the editor, to change some of the labels, change placeholders, reorder fields.

Since we already have our own form blocks like Mailchimp, Subscription, and the Form block, I think we should aim for a somewhat consistent experience between all those.

You can read about the rationale in pb5gDS-iT-p2

@Copons
Copy link
Contributor Author

Copons commented Feb 24, 2020

@jeherve @davemart-in
In 8e665f9 I've tried having the form work almost like the Contact Form block.

Feb-24-2020 13-20-40

The two blocks' needs are slightly different, so the implementation is slightly different as well.
Revue format is strict: a required email field called member[email] and two optional name fields called member[first_name] and member[last_name].
Contact Form can be customized entirely by adding all kinds of fields, removing them, changing their IDs, etc.

So, instead of having a container block with fields as children blocks (like Contact Form), I've hardcoded the three fields (names are still toggleable from the sidebar), and made the label and placeholder customizable.

To customize the label, I've had to add a new prop to Contact Form's JetpackFieldLabel; it's not a breaking change, but it adds a few lines of code to the diff.

Now: I realize this is a very last minute change, so if we think it's too big to be tested properly, I can drop it from the PR and open it in a follow up.

Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

This looks good to me. I only have some minor comments.

>
<div>
<label>
<?php echo $email_label; ?>
Copy link
Member

Choose a reason for hiding this comment

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

Should we escape this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You're right, this was a big distraction 😞

Updated in b9aa5a0

extensions/blocks/revue/revue.php Outdated Show resolved Hide resolved
@glendaviesnz
Copy link
Contributor

@davemart-in with Calendly, OpenTable and Google Cal, we removed the Edit option in the block tool bar which took the block back to preview mode to update the embed code, and instead added the embed code setting to the sidebar.

In the Review block it has the edit option in the toolbar to update the username, should this be moved into the settings panel also for consistency with the other blocks?

<TextControl
label={
<JetpackFieldLabel
label={ emailLabel }
Copy link
Contributor

Choose a reason for hiding this comment

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

A very minor thing, but in the edit view of the label field the text is not vertically centred, but in the other form fields it is:
Screen Shot 2020-02-25 at 9 52 15 AM


const saveUsername = event => {
event.preventDefault();
setAttributes( { revueUsername: username } );
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we add a .trim() to username here? currently if a user copies and pastes some spaces along with their username by mistake they get a 404 from revue when trying to submit the form.

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Feb 24, 2020
Copy link
Member

@jeherve jeherve left a comment

Choose a reason for hiding this comment

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

I think we're in a good place now, and I would suggest merging this as is and addressing the feedback that was left in future PRs.

ob_start();
?>

<div class="wp-block-jetpack-revue">
Copy link
Member

Choose a reason for hiding this comment

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

Let's use Jetpack_Gutenberg::block_classes() here maybe?

Copy link
Contributor

@glendaviesnz glendaviesnz left a comment

Choose a reason for hiding this comment

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

I agree with @jeherve, this is in a good place to merge now and then follow up with another PR for the other suggested changes.

@jeherve jeherve merged commit c70ed04 into master Feb 24, 2020
@jeherve jeherve deleted the add/revue-block branch February 24, 2020 23:10
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Feb 24, 2020
@jeherve
Copy link
Member

jeherve commented Feb 24, 2020

Merging for now. @Copons I'll let you handle the WordPress.com part as well as the remaining feedback? Thank you!

@jeherve jeherve added [Status] Needs Testing We need to add this change to the testing call for this month's release [Status] Has Changelog and removed [Status] Needs Changelog [Status] Needs Testing We need to add this change to the testing call for this month's release labels Feb 24, 2020
jeherve added a commit that referenced this pull request Feb 25, 2020
@davemart-in
Copy link
Contributor

davemart-in commented Feb 25, 2020

@davemart-in with Calendly, OpenTable and Google Cal, we removed the Edit option in the block tool bar which took the block back to preview mode to update the embed code, and instead added the embed code setting to the sidebar.
In the Review block it has the edit option in the toolbar to update the username, should this be moved into the settings panel also for consistency with the other blocks?

As @jeherve suggested, I think this is good enough to ship.

I thinking circling back around and updating this block to remove the Edit option is a good idea after this first iteration ships. Let's go ahead and move that to the sidebar at that point.

@Copons
Copy link
Contributor Author

Copons commented Feb 25, 2020

r203320-wpcom

jeherve added a commit that referenced this pull request Feb 25, 2020
* 8.3 release: changelog

* Changelog: add #14516

* Changelog: add #14574

* Bring in changes from 8.2.1 and 8.2.2

* Update stable version

* Bring in 8.2.3 changes

* Changelog: add #14714

* Changelog: add #14639

* Changelog: add #14678

* Changelog: add #14673

* Changelog: add #14687

* Changelog: add #14704

* Changelog: add #14702

* Changelog: add #14541

* Changelog: add #14657

* Changelog: add #14622

* Changelog: add #14582

* Changelog: add #14638

* Changelog: add #14633

* Changelog: add #14571

* Changelog: add #14592

* Changelog: add #14539

* Changelog: add #14514

* Changelog: add #14643

* Changelog: add #14494

* Changelog: add #13739

* Changelog: add #14707

* Changelog: add #14736

* Changelog: add #14706

* Changelog: add #14730

* Changelog: add #14685

* Changelog: add #14727

* Changelog: add #14711

* Changelog: add #14742

* Changelog: add #14746

* Changelog: add #14725

* Changelog: add #13999

* Changelog: add #14740

* Changelog: add #14759

* Changelog: add #14703

* Changelog: add #14753

* Changelog: add #14754

* Changelog: add #14645

* Cahngelog: add #14599
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Revue [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Touches WP.com Files [Type] Feature Request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants