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

Social: Consolidate social initial state #38606

Merged
merged 74 commits into from
Aug 12, 2024

Conversation

manzoorwanijk
Copy link
Member

@manzoorwanijk manzoorwanijk commented Jul 30, 2024

Based off of #38430, this PR serves as an example of how to use the consolidated initial state.

This is a minimal version of what changes we need to make to get the job done (https://github.com/Automattic/jetpack-reach/issues/135). For now it uses the new initial state only for the useAdminUiV1 feature flag. Moving forward, we will need to update the initial state from the backend and also update the corresponding js logic.

Proposed changes:

  • Use the consolidated initial of Jetpack to render the Social Initial state
  • Use the rendered Social initial state for useAdminUiV1 feature flag on Social admin page

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:

  • Go to Social admin page
  • Confirm that you see the "Connect accounts" button when there are no connections
  • Confirm that clicking on the button opens the connections management modal
  • Confirm that you see the connections list
  • Confirm that nothing changes in the editor and Jetpack settings page for both Jetpack and WPCOM sites
  • For WoA sites, you may need to jetpack build plugins/wpcomsh and jetpack rsync wpcomsh to mu-plugins
  • If you use Query Monitor plugin (which you always should), you can check the script dependencies for Social admin page.
  • Do a sanity check for simple and atomic sites to ensure all is OK.

@manzoorwanijk manzoorwanijk self-assigned this Jul 30, 2024
Copy link
Contributor

github-actions bot commented Jul 30, 2024

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 update/consolidate-social-state 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 update/consolidate-social-state
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/consolidate-social-state
    

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

@github-actions github-actions bot added [JS Package] Publicize Components [Package] Publicize [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Social Issues about the Jetpack Social plugin [Status] In Progress labels Jul 30, 2024
@github-actions github-actions bot added [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] Wpcomsh Docs labels Aug 7, 2024
@manzoorwanijk manzoorwanijk marked this pull request as ready for review August 7, 2024 15:55
Copy link
Contributor

@spsiddarthan spsiddarthan left a comment

Choose a reason for hiding this comment

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

I have asked some questions and added some thoughts. Might be a good idea to get together and chat about it tomorrow.

@spsiddarthan
Copy link
Contributor

Left some thoughts, copying @gmjuhasz to add his as well.

Copy link
Contributor

@spsiddarthan spsiddarthan left a comment

Choose a reason for hiding this comment

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

Left a thought on the way we configure the assets.

Instead of commenting out, let's get rid of functions and variables we don't use. We can come back to this PR's history to add them back.

projects/packages/publicize/actions.php Show resolved Hide resolved
@manzoorwanijk
Copy link
Member Author

Instead of commenting out, let's get rid of functions and variables we don't use. We can come back to this PR's history to add them back.

Done. Thanks

Copy link
Contributor

@spsiddarthan spsiddarthan left a comment

Choose a reason for hiding this comment

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

This looks good and I think is really close. It tests well per the instructions.

I am pinging @gmjuhasz for a second look and testing. I don't know how to test using the Query Monitor plugin, so I didn't do that, but I will do that after pairing with either of you next week.

Copy link
Contributor

@gmjuhasz gmjuhasz left a comment

Choose a reason for hiding this comment

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

Tests well just had some small questions. If this is done and we migrate all other initial state, what else do we need to deprecate?

@@ -1,3 +1,12 @@
export interface FeatureFlags {
useAdminUiV1: boolean;
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we have to add the new feature flag for the modal as well?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we need to migrate all our initial state to this new consolidated one.

/**
* Publicize_Script_Data class.
*/
class Publicize_Script_Data {
Copy link
Contributor

Choose a reason for hiding this comment

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

I am a bit confused here what the class name "Script data" means. Could we have a more descriptive doc if this describes the class the best?

Copy link
Member Author

Choose a reason for hiding this comment

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

Actually the package we created in #38430 was initially named as initial-state and the class was also named as Jetpack_Initial_State but after some discussion with Garage team, we reached the conclusion to use the word script data which is what the initial state actually is. Also, WordPress uses the similar nomenclature for such data - wp_add_inline_script has calls the second argument as $data and likewise the other such functions.

Comment on lines +120 to +136
public static function has_feature_flag( $feature ): bool {
$flag_name = str_replace( '-', '_', $feature );

// If the option is set, use it.
if ( get_option( 'jetpack_social_has_' . $flag_name, false ) ) {
return true;
}

$constant_name = 'JETPACK_SOCIAL_HAS_' . strtoupper( $flag_name );
// If the constant is set, use it.
if ( defined( $constant_name ) && constant( $constant_name ) ) {
return true;
}

return Current_Plan::supports( 'social-' . $feature );
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We have this in publicize-base with my previous changes, would that be deprecated?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, we will eventually move to this new consolidated logic.

@manzoorwanijk
Copy link
Member Author

If this is done and we migrate all other initial state, what else do we need to deprecate?

Yes, we will need to gradually migrate to the new initial state. We can do that in small PRs to make testing easier. After we are done doing that, we can come back to Unbundling publicize from Jetpack and Social - the idea that actually gave birth to this one.

@manzoorwanijk manzoorwanijk requested a review from gmjuhasz August 12, 2024 09:54
Copy link
Contributor

@gmjuhasz gmjuhasz 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 per the instuctions and looks okay to merge

@manzoorwanijk manzoorwanijk merged commit 065c5cb into trunk Aug 12, 2024
73 checks passed
@manzoorwanijk manzoorwanijk deleted the update/consolidate-social-state branch August 12, 2024 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DO NOT MERGE don't merge it! Docs E2E Tests [JS Package] Publicize Components [JS Package] Script Data [JS Package] Webpack Config [Package] Assets [Package] Publicize [Plugin] Automattic For Agencies Client [Plugin] Backup A plugin that allows users to save every change and get back online quickly with one-click restores. [Plugin] Boost A feature to speed up the site and improve performance. [Plugin] Classic Theme Helper Plugin [Plugin] CRM Issues about the Jetpack CRM plugin [Plugin] Inspect [Plugin] Jetpack Issues about the Jetpack plugin. https://wordpress.org/plugins/jetpack/ [Plugin] Migration [Plugin] mu wpcom jetpack-mu-wpcom plugin [Plugin] Protect A plugin with features to protect a site: brute force protection, security scanning, and a WAF. [Plugin] Search A plugin to add an instant search modal to your site to help visitors find content faster. [Plugin] Social Issues about the Jetpack Social plugin [Plugin] Starter Plugin [Plugin] VideoPress A standalone plugin to add high-quality VideoPress videos to your site. [Plugin] Wpcomsh RNA [Tests] Includes Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants