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

feat: Enable Jetpack collection for native block inserter #25092

Merged
merged 6 commits into from
Jul 15, 2022

Conversation

dcalhoun
Copy link
Member

@dcalhoun dcalhoun commented Jul 13, 2022

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:

  • The web editor displays a collection of Jetpack blocks in the block inserter for non-WordPress.com, Jetpack-connected sites. This change enables that same collection display for the native block inserter.
  • Rename the collection from "Jetpack" to "Jetpack powered" for the native block inserter.
  • Add a separate block-category.native.js file to configure native platform without adding additional code/complexity to the web bundle.

Other information:

  • Have you written new tests for your changes, if applicable?
  • Have you checked the E2E test CI results, and verified that your changes do not break them?

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.

@dcalhoun dcalhoun added [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ labels Jul 13, 2022
@dcalhoun dcalhoun self-assigned this Jul 13, 2022
@matticbot
Copy link
Contributor

Caution: This PR has changes that must be merged to WordPress.com
Hello dcalhoun! These changes need to be synced to WordPress.com - If you 're an a11n, please commandeer and confirm D84214-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
Copy link
Contributor

github-actions bot commented Jul 13, 2022

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: August 2, 2022.
  • Scheduled code freeze: July 25, 2022.

@github-actions github-actions bot added the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jul 13, 2022
dcalhoun added 3 commits July 14, 2022 18:07
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.
@dcalhoun dcalhoun force-pushed the feat/enable-jetpack-collection-for-native-inserter branch from 52dc994 to ac90801 Compare July 14, 2022 23:21
@dcalhoun dcalhoun removed the [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! label Jul 14, 2022
The collection title is now rendered to make dark mode support easier.
Comment on lines 5 to 8
registerBlockCollection( 'jetpack', {
title: 'Jetpack powered',
icon: <JetpackLogo />,
} );
Copy link
Member Author

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:

  1. The isWpCom conditional is removed (this check relies upon window and does not work for the native editor).
  2. 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.

Copy link
Contributor

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?

Copy link

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).

Copy link
Member Author

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?

Copy link
Contributor

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.

Copy link
Contributor

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?

Copy link
Member Author

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, including isJetpack 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. 👍🏻

Copy link
Contributor

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 a isJetpack 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 👍 .

Copy link
Member Author

@dcalhoun dcalhoun Jul 15, 2022

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'.

Copy link
Contributor

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.

@dcalhoun dcalhoun requested a review from SiobhyB July 15, 2022 01:36
SiobhyB
SiobhyB previously approved these changes Jul 15, 2022
Copy link

@SiobhyB SiobhyB left a 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).

@dcalhoun
Copy link
Member Author

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. 🙇🏻

@dcalhoun dcalhoun marked this pull request as ready for review July 15, 2022 15:35
@dcalhoun dcalhoun added [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. and removed [Status] In Progress labels Jul 15, 2022
@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from fellow Jetpack developers. Label will be renamed soon. labels Jul 15, 2022
@jeherve jeherve added this to the jetpack/11.2 milestone Jul 15, 2022
@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 Jul 15, 2022
@jeherve jeherve enabled auto-merge (squash) July 15, 2022 15:44
@jeherve
Copy link
Member

jeherve commented Jul 15, 2022

r249105-wpcom

@jeherve jeherve merged commit 05e4647 into trunk Jul 15, 2022
@jeherve jeherve deleted the feat/enable-jetpack-collection-for-native-inserter branch July 15, 2022 15:55
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Jul 15, 2022
@github-actions
Copy link
Contributor

Great news! One last step: head over to your WordPress.com diff, D84214-code, and deploy it.
Once you've done so, come back to this PR and add a comment with your SVN changeset ID (e.g. r12345-wpcom).

Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ Touches WP.com Files [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants