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

Extensions: Add block editor (Gutenberg) extensions source #11633

Merged
merged 1 commit into from
Mar 25, 2019

Conversation

roccotripaldi
Copy link
Member

@roccotripaldi roccotripaldi commented Mar 20, 2019

Fixes nothing, aside from developer headaches

Changes proposed in this Pull Request:

This PR copies the javascript from the wpcalypso repo, and into Jetpack, with the hopes of building the blocks from here in Jetpack, where their PHP code lives.

Testing instructions:

  • Does the file structure make sense?
  • Try building:
    1. copy extensions/blocks folder into your local calypso at packages/jetpack-blocks/src/blocks
    2. In packages/jetpack-blocks/src/blocks run npm install
    3. In calypso root run npx lerna run build --stream --scope='@automattic/jetpack-blocks' -- -- --output-path /path-to-jetpack/_inc/blocks
    4. Does it build ok?

Proposed changelog entry for your changes:

  • Adding source code for Jetpack blocks

@roccotripaldi roccotripaldi added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. [Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack labels Mar 20, 2019
@roccotripaldi roccotripaldi added this to the 7.2 milestone Mar 20, 2019
@roccotripaldi roccotripaldi requested review from a team March 20, 2019 21:13
@jetpackbot
Copy link
Collaborator

jetpackbot commented Mar 20, 2019

Thank you for the great PR description!

When this PR is ready for review, please apply the [Status] Needs Review label. If you are an a11n, please have someone from your team review the code if possible. The Jetpack team will also review this PR and merge it to be included in the next Jetpack release.

Scheduled Jetpack release: April 2, 2019.
Scheduled code freeze: March 26, 2019

Generated by 🚫 dangerJS against a59fb1f

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.

Not to throw a wrench into this or anything, but in #11312 we had discussed a somewhat different file organization:

12fa4fd#diff-bf97bdc65b5272e6bbde848e059bdd4eR14

I'm fine either way but wanted to point this out. Wouldn't it be cleaner / easier to handle/build to have the jsx in their own folders?Not to throw a wrench into this or anything, but in #11312 we had discussed a somewhat different file organization:

12fa4fd#diff-bf97bdc65b5272e6bbde848e059bdd4eR14

I'm fine either way but wanted to point this out. Wouldn't it be cleaner / easier to handle/build to have the jsx in their own folders?

@simison
Copy link
Member

simison commented Mar 21, 2019

@jeherve @lezama @sirreal and I discussed folder structure and concluded to keep it as flat (opposed to splitting js+scss files to client/ and php files to backend/ folders.)

Gutenberg also has flat structure:

https://github.com/WordPress/gutenberg/tree/95642a40ca5dddbaf93a565d9a78a554974a3e0e/packages/block-library/src/search

Concern was that it would be confusing for complicated blocks with several files and that's also how Jetpack Dashboard files are split.

We can iterate once we do have more files/complex blocks (instead of optimizing early).

One aspect was to try match "single block plugin" proposal (https://make.wordpress.org/meta/2019/03/08/the-block-directory-and-a-new-type-of-plugin) but that's also something we might not want to optimize too early for, just keep it in mind:

To begin with, Single Block Plugins will contain a single PHP file containing plugin headers and initialization code only. Eventually, this should become unnecessary.

@simison
Copy link
Member

simison commented Mar 21, 2019

This depends on including files to ignores in different places before this is merged: #11639

(we could just bring those changes over to this PR)

@matticbot
Copy link
Contributor

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

@roccotripaldi roccotripaldi force-pushed the add/jetpack-blocks-src branch from e476f5a to 928a710 Compare March 21, 2019 19:34
@matticbot
Copy link
Contributor

roccotripaldi, Your synced wpcom patch D25865-code has been updated.


```
.
└── blockname/
└── blockname.php ← PHP file where the block and its assets are registered.
└── block-or-plugin-name/
Copy link
Member

Choose a reason for hiding this comment

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

In #11333 (unmerged) @ockham suggested separate folder for Plugins: extensions/plugins/seo/seo.php

Thoughts?

Copy link
Member

@simison simison Mar 21, 2019

Choose a reason for hiding this comment

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

Suppose extension could be both plugins and blocks (and filters and whatnot) at the same time, so it might not make sense to optimize this way?

Copy link
Member

Choose a reason for hiding this comment

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

It may be easier for our build tools and for new contributors if everything was in one place?

Copy link
Member

Choose a reason for hiding this comment

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

Does /extensions/blocks then make sense and should we just have /extensions ?

Copy link
Member

Choose a reason for hiding this comment

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

I believe the things in /blocks are actually blocks.

#11640 includes additional extensions (the sidebar and category) that aren't blocks. They are not located under blocks.

@roccotripaldi
Copy link
Member Author

We can ignore the failing wpcom sync and manually sync the file in a different phabricator.

@simison simison changed the title Extensions: Adds javascript / jsx for Jetpack blocks Extensions: Adds Jetpack blocks JavaScript and Sass files Mar 22, 2019
@kraftbj
Copy link
Contributor

kraftbj commented Mar 22, 2019

Assigning to @jeherve for the review, scheduled for review today.

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.

The blocks seem to build nicely. I do have some questions though.

Should the imported blocks be free of eslint errors? I would assume so since we have Prettier running in Calypso. I can currently see errors like this one, in extensions/shared/frontend-management.js:

Import individual methods from the Lodash module.

Since switching from jsx to js, we also have a few errors like this one, in extensions/shared/help-message.js or in extensions/shared/jetpack-plugin-sidebar.js for example:

'React' must be in scope when using JSX

@simison
Copy link
Member

simison commented Mar 22, 2019

We'll need to bring this change here when the PR merges: Automattic/wp-calypso#31690

@lezama lezama force-pushed the add/jetpack-blocks-src branch from 3436b67 to e8aa49e Compare March 22, 2019 21:13
@jeherve
Copy link
Member

jeherve commented Mar 22, 2019

I would be tempted to close this PR in favor of #11639 now that the commits are included in that other PR as well, but there are still some questions above that I think would be worth discussing.

@sirreal
Copy link
Member

sirreal commented Mar 25, 2019

I've pulled the jsx -> js rename commit 2cdb5b2 over from #11639

@sirreal
Copy link
Member

sirreal commented Mar 25, 2019

I would be tempted to close this PR in favor of #11639 now that the commits are included in that other PR as well, but there are still some questions above that I think would be worth discussing.

I've cleaned up #11639 significantly so these should be independent again.

ockham
ockham previously approved these changes Mar 25, 2019
Copy link
Contributor

@ockham ockham left a comment

Choose a reason for hiding this comment

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

This seems to be working well for me. Let's get #11639 merged and this one soon afterwards to reduce the duplication (and confusion) for developers. I think it's fine to address lint errors etc after the fact.

@sirreal sirreal force-pushed the add/jetpack-blocks-src branch from b5a1dc1 to c3847b9 Compare March 25, 2019 17:04
@sirreal sirreal changed the title Extensions: Adds Jetpack blocks JavaScript and Sass files Extensions: Add block editor (Gutenberg) extensions source Mar 25, 2019
@sirreal
Copy link
Member

sirreal commented Mar 25, 2019

I've just updated and squashed this branch to include the latest Calypso master source (as of Automattic/wp-calypso@0f0ba7b).

Ready for review.

The source for block editor (Gutenberg) extensions was stored in the
Calypso repository:

https://github.com/Automattic/wp-calypso

Move the source into this repository.
@sirreal sirreal force-pushed the add/jetpack-blocks-src branch from c3847b9 to a59fb1f Compare March 25, 2019 17:23
@kraftbj kraftbj added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Mar 25, 2019
Copy link
Contributor

@lezama lezama left a comment

Choose a reason for hiding this comment

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

:partyparrot: :shipit: 🚢 IT

@roccotripaldi roccotripaldi merged commit a2bf967 into master Mar 25, 2019
@ghost ghost removed the [Status] Ready to Merge Go ahead, you can push that green button! label Mar 25, 2019
@kraftbj kraftbj deleted the add/jetpack-blocks-src branch March 25, 2019 18:51
kraftbj added a commit that referenced this pull request Mar 26, 2019
kraftbj added a commit that referenced this pull request Mar 26, 2019
* Revert "Add source for Gutenberg extensions (#11633)"

This reverts commit a2bf967.

* Revert "Build: Prepare tooling for Gutenberg extensions in Jetpack (#11639)"

This reverts commit 0d14622.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Focus] Blocks Issues related to the block editor, aka Gutenberg, and its extensions developed in Jetpack Touches WP.com Files
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants