-
Notifications
You must be signed in to change notification settings - Fork 798
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
feat: Enable Jetpack collection for native block inserter #25092
feat: Enable Jetpack collection for native block inserter #25092
Conversation
Caution: This PR has changes that must be merged to WordPress.com |
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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. Jetpack plugin:
|
The native editor now displays collections within the block inserter. Specifically, a collection of Jetpack blocks is displayed with "Jetpack powered" badge within the inserter.
Changes green background to white.
52dc994
to
ac90801
Compare
The collection title is now rendered to make dark mode support easier.
registerBlockCollection( 'jetpack', { | ||
title: 'Jetpack powered', | ||
icon: <JetpackLogo />, | ||
} ); |
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.
There are only two differences between this native file and the sibling web file:
- The
isWpCom
conditional is removed (this check relies uponwindow
and does not work for the native editor). - Changing the collection title from "Jetpack" to "Jetpack powered."
A separate native file feels a bit excessive for such small differences, but it is likely for the best so that (1) the web bundle size does not increase with native code and (2) a misleading isWpCom
no-op is not run for the native editor.
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.
@dcalhoun I'm wondering if this should only be enabled for the WordPress app, probably showing the Jetpack logo in the Jetpack app would be a bit redundant, wdyt?
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.
+1 to this seeming a bit redundant for the Jetpack app, but not necessarily a blocker to merging if limiting it to only the WP app proves to be complex (especially as the eventual plan is to remove it).
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.
That is a great thought. I agree displaying "Jetpack powered" within the Jetpack app may be redundant.
@fluiddot @SiobhyB what approach do you think might be appropriate for controlling this?
We would need to set/access a value indicating the WordPress/Jetpack app and/or site type prior to the point we invoke block collection registration.
I perceive the capabilities
to be of similar nature, but they target individual features, and do not describe a higher-level app/site "type." Relatedly, the Jetpack plugin houses a set of utilities for determining site type, but they are incompatible with the native context.
We could possibly check each of the Jetpack block capabilities...
if (mediaFilesCollectionBlock || contactInfoBlock || tiledGalleryBlock) {
// register Jetpack block collection
}
...or add a new Jetpack site/app capability.
if (capabilities.jetpack) {
// register Jetpack block collection
}
Are there alternative approaches I am overlooking?
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.
+1 to this seeming a bit redundant for the Jetpack app, but not necessarily a blocker to merging if limiting it to only the WP app proves to be complex (especially as the eventual plan is to remove it).
Good point, I also think that only enabling it for the WP app shouldn't be a blocker.
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.
Are there alternative approaches I am overlooking?
I noticed that in the iOS native side we're using an object named AppConfiguration
that contains different flags, including isJetpack
to determine if the app is the Jetpack one. As an example, this flag is being used for determining when the Jetpack banner should be displayed (reference), so we could use that value for this too.
In relation to how we could pass this information to RN side, I was thinking to have a new capability or initial prop to identify the client. This way we could enable/disable the block collection depending on the client (i.e. the app), wdyt?
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.
I noticed that in the iOS native side we're using an object named
AppConfiguration
that contains different flags, includingisJetpack
to determine if the app is the Jetpack one.
Agreed. This does seem the most appropriate flag to use. Thanks for sharing.
In relation to how we could pass this information to RN side, I was thinking to have a new capability or initial prop to identify the client. This way we could enable/disable the block collection depending on the client (i.e. the app), wdyt?
As I consider it further, setting the app type within capabilities
feels a bit inappropriate. I imagine it makes more sense to have a isJetpack
boolean within the editor props/settings.
I can begin work to limit when the "Jetpack powered" badge displays, but it looks like the consensus is that work should not block merging this work. 👍🏻
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.
As I consider it further, setting the app type within
capabilities
feels a bit inappropriate. I imagine it makes more sense to have aisJetpack
boolean within the editor props/settings.
True, although this would imply adding it to Gutenberg and hence, add a reference to Jetpack 😅. An alternative could be to generate a different RN bundle for each WordPress and Jetpack app. This way we could set global constants similar to how it's done on the native side with AppConfiguration for each app. In fact, this option might be necessary in the future for overriding the colors of the editor for example.
I can begin work to limit when the "Jetpack powered" badge displays, but it looks like the consensus is that work should not block merging this work. 👍🏻
Yep, let's wrap up this task first and then focus on how we can identify in the editor the app that is being run 👍 .
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.
True, although this would imply adding it to Gutenberg and hence, add a reference to Jetpack 😅.
I wondered this myself. I hoped we might be able to strip out the value within gutenberg-mobile
's editor setup code, but we may still run into issue where the new property may have to be defined within react-native-bridge
protocols.
An alternative could be to generate a different RN bundle for each WordPress and Jetpack app. This way we could set global constants similar to how it's done on the native side with AppConfiguration for each app. In fact, this option might be necessary in the future for overriding the colors of the editor for example.
Another alternative might be to define a generic host app identifier, e.g. hostAppNamespace: 'jetpack'|'wordpress'|'awesome-future-app'
.
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.
Another alternative might be to define a generic host app identifier, e.g.
hostAppNamespace: 'jetpack'|'wordpress'|'awesome-future-app'
.
Yeah, this is aligned to what I commented about passing the editor's client, although I agree that hostAppNamespace
sounds more accurate.
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.
Approving following the review at WordPress/gutenberg#42405 (review), with the understanding there will likely be a follow up task to limit this change to the WP app.
In addition, we'll need to get approval from the Jetpack team before this PR's merged (the [Status] Needs Review
label can be used to get this final review).
Thank you, Siobhan! Marking this as ready for review by the Jetpack crew now. Note for the crew: I don't have commit access for WP.com, so would be grateful if you could handle committing to WP.com for me too. 🙇🏻 |
projects/plugins/jetpack/extensions/shared/block-category.native.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Jeremy Herve <[email protected]>
r249105-wpcom |
Great news! One last step: head over to your WordPress.com diff, D84214-code, and deploy it. Thank you! |
Display a collection of Jetpack blocks within the native block inserter to increase brand awareness during the Jetpack app migration.
Changes proposed in this Pull Request:
block-category.native.js
file to configure native platform without adding additional code/complexity to the web bundle.Other information:
Jetpack product discussion
p9ugOq-33V-p2
Does this pull request change what data or activity we track or use?
No.
Testing instructions:
See wordpress-mobile/gutenberg-mobile#5024.