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

Fix post editor dirty state caused by publicize store #34064

Merged
merged 13 commits into from
Nov 14, 2023

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Nov 10, 2023

Opening the Jetpack sidebar on the post edit page results in dirty state of the post editor and thus preventing users from reloading or navigating away from the page.

Screenshot 2023-11-13 at 12 39 17 PM

Proposed changes:

  • Move the connections state and actions from jetpack/publicize to jetpack-social-store and update consumer components to use the new store.
  • The source of truth for the connections will now be jetpack-social-store instead of post meta.
  • Connections in post meta will only be synced to post meta when a user explicitly toggles a connection

Note:
After this PR, the store inside projects/js-packages/publicize-components/src/store technically contains the utility functions not the actual selectors or actions because they mostly talk to the core/editor store not the jetpack/publicize store. That means we can convert those selectors/actions to simple utility functions and get rid of jetpack/publicize store.

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:

  • Run jetpack build plugins/jetpack
  • Ensure that you have some social connections added for the site
  • Goto post edit page for an existing post and open Jetpack sidebar
  • Wait for the connection-test-results API request to finish
  • Try to reload the page
  • Confirm that their is no confirmation popup about unsaved changes
  • Toggle a connection
  • Confirm that the UI reflects the toggled connection state
  • Try to reload the page
  • Confirm that this time you see the popup
  • Confirm that the social preview details like name and profile picture work correctly
  • Create a new post and publish it
  • Confirm that it is posted to the social media connections

Copy link
Contributor

github-actions bot commented Nov 10, 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/editor-dirty-state-by-publicize 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/editor-dirty-state-by-publicize
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin fix/editor-dirty-state-by-publicize
    

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

Copy link
Contributor

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.

@manzoorwanijk manzoorwanijk changed the title Fixed post editor dirty state cause by publicize store Fixed post editor dirty state caused by publicize store Nov 10, 2023
@manzoorwanijk manzoorwanijk changed the title Fixed post editor dirty state caused by publicize store Fix post editor dirty state caused by publicize store Nov 10, 2023
@manzoorwanijk
Copy link
Member Author

Sorry, I had to push a few more changes to reduce some duplication to get the user profile details from the connection data.

Copy link
Contributor

@pablinos pablinos left a comment

Choose a reason for hiding this comment

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

This is working well for me, nice work! Do you think it would be worth adding some more tests?

@manzoorwanijk
Copy link
Member Author

Do you think it would be worth adding some more tests?

I have the tests ready and I can create another PR for that to keep this one smaller.

* Add dependency

* Add unit tests for connection selectors

* Add unit tests for connection actions

* Add changelog
Copy link
Contributor

@pablinos pablinos left a comment

Choose a reason for hiding this comment

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

This is working well for me and cleans up the state management a lot.

@manzoorwanijk manzoorwanijk enabled auto-merge (squash) November 14, 2023 11:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants