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

OpenTable Block #14220

Merged
merged 58 commits into from
Jan 15, 2020
Merged

OpenTable Block #14220

merged 58 commits into from
Jan 15, 2020

Conversation

scruffian
Copy link
Member

@scruffian scruffian commented Dec 12, 2019

This PR adds an OpenTable block, providing block-editor native equivalent functionality of the existing OpenTable embed.

It supports embed code pasted from the OpenTable widget creator:
https://www.opentable.com/widget/reservation/preview?rid=1&lang=en-US

Changes proposed in this Pull Request:

  • This PR adds a new block, jetpack/opentable.

opentable

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

New feature.

Internal reference: pb5gDS-er-p2

The goal would be to release it as a beta block first, in Jetpack 8.1.
Internal reference: p1576850286103100-slack-explorers

Testing instructions:

This is currently marked as a beta block, you will need to add define( 'JETPACK_BETA_BLOCKS', true ); to your wp-config.php file.

Proposed changelog entry for your changes:

  • Block Editor: Added a OpenTable block.

@jetpackbot
Copy link

jetpackbot commented Dec 12, 2019

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 294447f

@jeherve jeherve added [Block] OpenTable [Type] Feature Request [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Dec 12, 2019
@scruffian scruffian changed the title initial commit for the opentable block OpenTable Block Dec 16, 2019
@davemart-in
Copy link
Contributor

Nice work getting this stubbed out!

Here's what I'm currently seeing:

stubbed-out

In comparing the this current state of this PR to the design mockups we've still got quite a few things to clean up:

open-table-v1

Would it be helpful for me to go through and itemize the changes that still need to be made, or do you want to take another pass at cleaning things up first?

@jeherve jeherve added this to the 8.1 milestone Dec 20, 2019
@zinigor zinigor modified the milestones: 8.1, 8.2 Dec 30, 2019
@zinigor
Copy link
Member

zinigor commented Dec 30, 2019

Because this is still in progress as of now, I'm going to move this to the next milestone.

@Copons
Copy link
Contributor

Copons commented Jan 6, 2020

There are a few inconsistencies on the front end rendering, likely caused by some different CSS opinions between OpenTable and TwentyTwenty, that I think we should address.

Screenshot 2020-01-06 at 13 38 04Screenshot 2020-01-06 at 13 45 02

These should be a good start, but I'm not exactly sure how to enqueue in the "Jetpack way" front-end styles (view or style files) for dynamic blocks.

.ot-dtp-picker {
  box-sizing: content-box;

  .ot-title {
    margin: 4px auto 12px auto;
  }

  .ot-dtp-picker-selector-link {
    text-decoration: none;
  }

  input[type='submit'] {
    text-transform: none;
    padding: 0;
  }
}

@Copons
Copy link
Contributor

Copons commented Jan 6, 2020

I'm wondering about the UX of the restaurant picker with the FormTokenField which only displays the ID.
A few months ago, I've had a similar issue on an old (now removed) FSE feature: it was a post selector for a given CPT with an autocomplete popover list, which displayed the post title, and stored its ID.

If I'm not mistaken, this is the last version of that component before its removal: https://github.com/Automattic/wp-calypso/blob/3932cbd44a2a26897d233d094c9f44ad231c8ba8/apps/full-site-editing/full-site-editing-plugin/full-site-editing/components/post-autocomplete/index.js

What do y'all think if we adapted it (and modernized it with React hooks as well!) to use the OpenTable API?

@scruffian
Copy link
Member Author

What do y'all think if we adapted it (and modernized it with React hooks as well!) to use the OpenTable API?

Sounds like a good idea!

@pablinos
Copy link
Contributor

pablinos commented Jan 6, 2020

I was wondering about the UX of displaying just the ID, and I ran up against some problems.

Using the FormTokenField, I thought we could have it display the restaurant name and the ID, but the problem is that it gets a bit long sometimes.

Also, when I looked into doing that, I couldn't find a way of retrieving specific restaurant details by ID from the API endpoint we're using. There are a few problems with that, but one of the biggest is if someone enters their ID and it's a subset of another, like 432 and 4321. You nearly always get back restaurants with 432 in the name, street address, or with IDs starting and ending in 432, but never the restaurant with ID 432.

The only official OpenTable API I could find didn't seem to offer this information either, but if it did, we'd have to proxy the requests and I'm not sure how that would work with access tokens etc. It looks like you have to become a partner to use their Consumer API. We might want to go that route depending on what's involved.

As a side thought, would it be worth adding the features of your post autocomplete component to the FormTokenField, or maybe the whole thing as a new component to @wordpress/components? It seems like this would be generally useful.

@huguesvincent
Copy link

For the record, I filled this form back in December and approached a few folks at Open Table without any success so far. I'll keep trying to get on that whitelist.

@Copons
Copy link
Contributor

Copons commented Jan 7, 2020

Ah, I forgot about my PostAutocomplete component, it's not a good fit for this as it expects 1 selected results, while OpenTable allows for multiple.

Also, when I looked into doing that, I couldn't find a way of retrieving specific restaurant details by ID from the API endpoint we're using.

@pablinos Right, damn!
We could partly solve this by storing the restaurant name as a block attribute (not super elegant, but at least I don't expect folks to save dozens of restaurants in their OT blocks?), but that wouldn't help when pasting the embed code, which doesn't contain the restaurant names at all.

if someone enters their ID and it's a subset of another, like 432 and 4321. You nearly always get back restaurants with 432 in the name, street address, or with IDs starting and ending in 432, but never the restaurant with ID 432.

This is rather annoying.
We could be more transparent, and stop saying that the restaurant ID is an accepted value:
Something like this:

- Enter your restaurant name, OpenTable Restaurant ID or embed code
+ Enter your restaurant name, or paste an OpenTable Reservation Widget embed code

extensions/blocks/opentable/opentable.php Outdated Show resolved Hide resolved
extensions/blocks/opentable/restaurant-picker.js Outdated Show resolved Hide resolved
class.jetpack-plan.php Outdated Show resolved Hide resolved
class.jetpack-plan.php Outdated Show resolved Hide resolved
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 this should be good to go for now. I created issues for feedback that was discussed above and other things that I found while testing, but that are not blockers for this PR. I think we should be able to address those issues in follow-up PRs.

I'll merge this now.

#14344
#14346
#14335
#14345
#14343
#14347

@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 Jan 15, 2020
@jeherve jeherve merged commit c5a8824 into master Jan 15, 2020
@jeherve jeherve deleted the add/opentable branch January 15, 2020 11:11
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Jan 15, 2020
@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 Jan 15, 2020
jeherve added a commit that referenced this pull request Jan 17, 2020
jeherve added a commit that referenced this pull request Jan 28, 2020
* [not verified] Remove empty readme section

* Initial changelog for 8.2

* Changelog: add #14220

* Changelog: add #14252

* Changelog: add #14291

* Changelog: add #14309

* Changelog: add #14304

* Changelog: add general connection log.

* Changelog: add #14275

* Changelog: add #14313

* Changelog: add #14213

* Changelog: add #14357

* Add sync testing instructions

* Add 8.1.1 changelog back

See eeaafab and 61757eb

* Changelog: add #14371

* Changelog: add #14386

* Changelog: add #14471

* Changelog: add #14325

* Changelog: add #14194

* Changelog: add #14340

* Changelog: add #14418

* Changelog: add #14417

* Changelog: add #14075

* Changelog: add #14467

* Changelog: add #14307

* Changelog: add #14326
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] OpenTable [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.