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

Instagram Widget: Remove from legacy-widget block #21050

Merged
merged 11 commits into from
Sep 20, 2021

Conversation

arcangelini
Copy link
Contributor

Summary

With the new current widget block editor, the Instagram Widget does not configure properly. The current Instagram Gallery block already exists and offers the same functions. Rather than fixing the broken widget this PR removes it from the core/legacy-widget and adds the widget to the REST API to allow a block transform: to be created.

Fixes Automattic/wp-calypso#55344

Changes proposed in this Pull Request:

  • Added filter to hide wpcom_instagram_widget from legacy-widget block
  • Added widget_option to allow it to be displayed in the REST API. This will allow it to be "transformed" into the jetpack/instagram-gallery block

Jetpack product discussion

No discussions

Does this pull request change what data or activity we track or use?

No data changes

Testing instructions:

  • Got to Appearance ⇢ Customize ⇢ Widgets
  • Add a new block and select Legacy
  • In the dropdown check to make sure the Instagram (Jetpack) option is gone
  • Next search in the available blocks for "Instagram". You should no longer see a legacy block for Instagram.

@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello arcangelini! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D66722-code works as expected before merging this PR. Once this PR is merged, please commit the changes to WP.com. Thank you!
This revision will be updated with each commit to this PR

@github-actions github-actions bot added the [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ label Sep 11, 2021
@github-actions
Copy link
Contributor

github-actions bot commented Sep 11, 2021

Thank you for your PR!

When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:

  • ✅ Include a description of your PR changes.
  • ⚠️ All commits were linted before commit.
  • ✅ Add a "[Status]" label (In Progress, Needs Team Review, ...).
  • ✅ Add testing instructions.
  • ✅ Specify whether this PR includes any changes to data or privacy.
  • ✅ Add changelog entries to affected projects

This comment will be updated as you work on your PR and make changes. If you think that some of those checks are not needed for your PR, please explain why you think so. Thanks for cooperation 🤖


The e2e test report can be found here. Please note that it can take a few minutes after the e2e tests checks are complete for the report to be available.


Once your PR is ready for review, check one last time that all required checks (other than "Required review") appearing at the bottom of this PR are passing or skipped.
Then, add the "[Status] Needs Team review" label and ask someone from your team review the code.
Once you’ve done so, switch to the "[Status] Needs Review" label; someone from Jetpack Crew will then review this PR and merge it to be included in the next Jetpack release.


Jetpack plugin:

  • Next scheduled release: October 5, 2021.
  • Scheduled code freeze: September 28, 2021.

yansern
yansern previously approved these changes Sep 13, 2021
Copy link
Contributor

@yansern yansern left a comment

Choose a reason for hiding this comment

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

Tested & working!

Before:
image

After:
image

@yansern
Copy link
Contributor

yansern commented Sep 13, 2021

It looks like the E2E test needs to be updated.
image

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 works well. I have 2 remarks though:

  • I find the function name (hide_from_legacy_block) a bit confusing; I would personally find something like hide_widget_in_block_widget_editor maybe a bit clearer?
  • Would it be possible to put the function in the class instead of on its own outside of the class in the same file? I feel it would be cleaner, and would avoid any potential conflicts with functions with the same name in a different plugin.

Also, not for this PR, but I think it would be great if we could have a transform from the legacy widget to the block, to help move away from the widget.

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Team Review Obsolete. Use Needs Review instead. labels Sep 13, 2021
@arcangelini arcangelini added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Sep 14, 2021
Copy link
Contributor Author

@arcangelini arcangelini left a comment

Choose a reason for hiding this comment

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

Moved the filter into the _construct() and renamed the function

@arcangelini arcangelini requested a review from jeherve September 14, 2021 14:27
@arcangelini
Copy link
Contributor Author

arcangelini commented Sep 15, 2021

OK, it took me a little digging to understand how to build the transforms but I got it and added it to the instagram-gallery block and tested it. Do we need to add any other messages?

Also, the original widget had a title as you can see, but the block doesn't have that option. Should I also add a heading block above and either group them or leave them separate? Thoughts?

Screen Capture on 2021-09-15 at 17-17-04

@jeherve
Copy link
Member

jeherve commented Sep 15, 2021

OK, it took me a little digging to understand how to build the transforms but I got it and added it to the instagram-gallery block and tested it.

Nicely done, thank you! 👏

Do we need to add any other messages?

Is it possible to port the number of columns and the count to the block, so those settings remain?

Also, the original widget had a title as you can see, but the block doesn't have that option. Should I also add a heading block above and either group them or leave them separate? Thoughts?

Yeah, I think it would make sense to create a new heading block, and then group the heading and the Instagram block.

@jeherve jeherve added [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. and removed [Status] Needs Review This PR is ready for review. labels Sep 15, 2021
@simison
Copy link
Member

simison commented Sep 17, 2021

these blocks need to be wrapped in a group to keep them together,

What does "keeping them together" mean?

@arcangelini
Copy link
Contributor Author

@simison if you look at the screenshot that I took, when the heading and Instagram blocks are not bundled together in one group they have the propensity to end up in different footer columns. The two need to be nested in a group or column block to keep them together.

I am open to other suggestions because this has not been a very fun issue to solve for.

@simison
Copy link
Member

simison commented Sep 17, 2021

@arcangelini a solution is coming in Gutenberg 11.5: WordPress/gutenberg#32723

Meanwhile might make sense to get basic transform merged without heading, or by keeping heading separate block?

@arcangelini
Copy link
Contributor Author

The source of the issue is coming from this check. If the block transforming TO does not match the block where it is defined it returns null. This check does not take into account the nested innerBlocks. So any attempt to programmatically add any parent block will break.

@arcangelini arcangelini added [Status] Needs Review This PR is ready for review. and removed [Status] Needs Author Reply We need more details from you. This label will be auto-added until the PR meets all requirements. labels Sep 17, 2021
@arcangelini
Copy link
Contributor Author

Per @simison suggestion removed the header & group blocks in order to fix current issues. I am working to get the bug in Gutenberg fixed. Not sure on the timeline for that.

@jeherve jeherve added this to the jetpack/10.2 milestone Sep 17, 2021
@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review This PR is ready for review. labels Sep 17, 2021
jeherve
jeherve previously approved these changes Sep 17, 2021
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 works well for me. 🚢 !

@arcangelini
Copy link
Contributor Author

Deployed on WPCOM: r231968-wpcom

The failing test has to do with a core block test that was updated in the diff.

@arcangelini arcangelini merged commit 5b4a560 into master Sep 20, 2021
@arcangelini arcangelini deleted the update/instagram-widget-block-compatibility branch September 20, 2021 15:33
@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D66722-code, and commit it.
Once you've done so, come back to this PR and add a comment with your changeset ID.

Thank you!

@kraftbj kraftbj removed the [Status] Ready to Merge Go ahead, you can push that green button! label Sep 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Instagram Widget: Can never connect to Instagram account
6 participants