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

Add Jetpack Modules redux store to shared utils #33397

Merged
merged 34 commits into from
Nov 10, 2023

Conversation

andrii-lysenko
Copy link
Contributor

@andrii-lysenko andrii-lysenko commented Sep 29, 2023

Fixes https://github.com/Automattic/vulcan/issues/12

Proposed changes:

In order to have a consistent state of Modules statuses across Monorepo I think it would be beneficial to have a Modules Redux store. This eventually could replace (or enhance) hook useModuleStatus and give more information.

  • Creating Redux store for general information on Jetpack modules inside shared-extension-utils
  • Use selector and dispatch action to control the module state within Form package (and block)
  • Update withAiAssistantComponents HOC to use useIsPossibleToExtendJetpackFormBlock hook to have reactive data

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?
  • Have you tested your changes on WordPress.com, if applicable (if so, you'll see a generated comment below with a script to run)?

Jetpack product discussion

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

Testing instructions:

  • Clone this branch locally. You can run it with your Jurassic Tube setup.
  • In /wp-admin/admin.php?page=jetpack_modules verify that Contact Form module is disabled
  • Create new post /wp-admin/post-new.php and add new block
Screenshot at Oct 11 11-48-04
  • Verify that no AI assistant present, when block is disabled
  • Activate module. Verify that straight away the AI assistant is available
Screenshot at Oct 11 14-33-46
  • Check any additional implications you could think of with the module or AI assistatnt

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2023

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.
  • ✅ 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 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 reviewed, it can then be merged.
If you need an extra review from someone familiar with the codebase, you can update the labels from "[Status] Needs Team Review" to "[Status] Needs Review", and in that case Jetpack Approvers will do a final review of your PR.


Jetpack plugin:

The Jetpack plugin has different release cadences depending on the platform:

  • WordPress.com Simple releases happen daily.
  • WoA releases happen weekly.
  • Releases to self-hosted sites happen monthly. The next release is scheduled for December 5, 2023 (scheduled code freeze on November 28, 2023).

If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack.

@github-actions
Copy link
Contributor

github-actions bot commented Sep 29, 2023

Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.

  • To test on WoA, go to the Plugins menu on a WordPress.com Simple site. Click on the "Upload" button and follow the upgrade flow to be able to upload, install, and activate the Jetpack Beta plugin. Once the plugin is active, go to Jetpack > Jetpack Beta, select your plugin, and enable the fix/ai-assistant-form-blocks-sync branch.

    • For jetpack-mu-wpcom changes, also add define( 'JETPACK_MU_WPCOM_LOAD_VIA_BETA_PLUGIN', true ); to your wp-config.php file.
  • To test on Simple, run the following command on your sandbox:

    bin/jetpack-downloader test jetpack fix/ai-assistant-form-blocks-sync
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/ai-assistant-form-blocks-sync
    

Interested in more tips and information?

  • In your local development environment, use the jetpack rsync command to sync your changes to a WoA dev blog.
  • Read more about our development workflow here: PCYsg-eg0-p2
  • Figure out when your changes will be shipped to customers here: PCYsg-eg5-p2

@jeherve jeherve added the [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it label Sep 29, 2023
@andrii-lysenko andrii-lysenko marked this pull request as ready for review October 11, 2023 22:12
@andrii-lysenko andrii-lysenko requested a review from a team October 18, 2023 17:46
@CGastrell
Copy link
Contributor

Could use a .md with docs and examples/usage

@andrii-lysenko
Copy link
Contributor Author

@CGastrell Thanks for pointing this out. Added basic Readme. However, we might change it a bit in the future, providing a more accessible experience utilizing the hooks.

@jeherve
Copy link
Member

jeherve commented Oct 27, 2023

This doesn't seem to handle WordPress.com Simple just yet, where the contact form module is always active and that logic doesn't need to run.

I'm afraid this is still an issue on WordPress.com Simple:

image

@andrii-lysenko
Copy link
Contributor Author

@jeherve oh, I haven't got this from the first time. Thanks, I'll take a look.

@andrii-lysenko
Copy link
Contributor Author

@jeherve Sorry it took so long, due to ongoing support rotation. I pushed I believe a fix for this situation. The only thing does Atomic also considered simple? I'm wiring my logic around isSimpleSite() which I hope should be sufficient.

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 only thing does Atomic also considered simple? I'm wiring my logic around isSimpleSite() which I hope should be sufficient.

isSimpleSite() should be enough indeed! That's also what we do in useModuleStatus:

// On WordPress.com Simple sites, all modules are always active.
if ( isSimpleSite() ) {
return true;
}

@@ -42,6 +43,10 @@ export function* updateJetpackModuleStatus( settings ) {
* @returns {object} - an action object.
*/
export function* fetchModules() {
// We don't fetch modules for Simple Site and aknowledge that all modules are active
if ( isSimpleSite() ) {
return true;
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't it return an object instead, to match the expected return?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, good catch. Though, it's error in JSDoc, it should yield object but returns bool.

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 tests well for me. 🚢 !

@jeherve jeherve added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] In Progress labels Nov 10, 2023
@andrii-lysenko andrii-lysenko merged commit 968ea1e into trunk Nov 10, 2023
63 of 68 checks passed
@andrii-lysenko andrii-lysenko deleted the fix/ai-assistant-form-blocks-sync branch November 10, 2023 17:09
@github-actions github-actions bot added this to the jetpack/12.9 milestone Nov 10, 2023
@github-actions github-actions bot removed the [Status] Ready to Merge Go ahead, you can push that green button! label Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] AI Assistant [Block] Contact Form Form block (also see Contact Form label) Docs [Feature] Contact Form [JS Package] Shared Extension Utils [Package] Forms [Package] Search Contains core Search functionality for Jetpack and Search plugins [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ RNA [Tests] Includes Tests [Type] Enhancement Changes to an existing feature — removing, adding, or changing parts of it
Projects
No open projects
Status: In Progress
Development

Successfully merging this pull request may close these issues.

4 participants