Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Changes from 5 commits
577ac7b
e6d5b75
ac90801
fe810ca
7aacb9c
6073988
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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:
isWpCom
conditional is removed (this check relies uponwindow
and does not work for the native editor).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...
...or add a new Jetpack site/app capability.
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.
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.
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. 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.
Agreed. This does seem the most appropriate flag to use. Thanks for sharing.
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.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.
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.
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.
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 withinreact-native-bridge
protocols.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.
Yeah, this is aligned to what I commented about passing the editor's client, although I agree that
hostAppNamespace
sounds more accurate.