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: Hide license link on Social admin page of WoA sites #41076

Merged
merged 5 commits into from
Jan 15, 2025

Conversation

p-jackson
Copy link
Member

@p-jackson p-jackson commented Jan 15, 2025

Fixes Automattic/wp-calypso#98217

Proposed changes:

  • Adds a is_woa_site flag to the window.JetpackScriptData.social global
  • Hide the Already have an existing plan or license key? link on the Social plugin's admin page when the site is hosted on WoA

CleanShot 2025-01-15 at 16 10 30@2x

Hiding the license link in the admin page is the approach that Jetpack Boost took here when it had the equivalent issue here #36434

AFAICT there isn't an existing way to check whether the site is hosted on WoA in the client, so, like Boost, we have to add something to a global. (Boost uses it's own window.Jetpack_Boost global which contains this data

return Jetpack_Boost.site.host === 'woa';
)

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

The issue described in Automattic/wp-calypso#98217 is that the user can end up on an access denied page after clicking the Add an existing license link.

image

This is because the My Jetpack page is hidden on WoA sometimes; specifically when the admin interface style is set to "Default" (aka use Calypso instead of wp-admin)

There's been discussion here Automattic/wp-calypso#98217 (comment) and here https://github.com/Automattic/dotcom-forge/issues/5663#issuecomment-1953388803 about whether we should just open up the My Jetpack page in all cases. This PR doesn't answer that discussion.

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

Nope

Testing instructions:

  • Follow these instructions for setting up this diff on your WoA test site
  • The standalone Jetpack Social plugin needs to be installed
  • Nav to /wp-admin/admin.php?page=jetpack-social
  • Confirm the Already have an existing plan or license key? link is hidden
  • Test using jurassic.ninja; the link should appear

Copy link
Contributor

github-actions bot commented Jan 15, 2025

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/social/hide-license-on-woa 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/social/hide-license-on-woa
    
    bin/jetpack-downloader test jetpack-mu-wpcom-plugin update/social/hide-license-on-woa
    

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

github-actions bot commented Jan 15, 2025

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 a "[Type]" label (Bug, Enhancement, Janitorial, Task).
  • ✅ 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.


Follow this PR Review Process:

  1. Ensure all required checks appearing at the bottom of this PR are passing.
  2. Choose a review path based on your changes:
    • A. Team Review: add the "[Status] Needs Team Review" label
      • For most changes, including minor cross-team impacts.
      • Example: Updating a team-specific component or a small change to a shared library.
    • B. Crew Review: add the "[Status] Needs Review" label
      • For significant changes to core functionality.
      • Example: Major updates to a shared library or complex features.
    • C. Both: Start with Team, then request Crew
      • For complex changes or when you need extra confidence.
      • Example: Refactor affecting multiple systems.
  3. Get at least one approval before merging.

Still unsure? Reach out in #jetpack-developers for guidance!


Social plugin:

  • Next scheduled release: none scheduled.

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

@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 Jan 15, 2025
@p-jackson p-jackson added the [Type] Bug When a feature is broken and / or not performing as intended label Jan 15, 2025
@p-jackson p-jackson self-assigned this Jan 15, 2025
@p-jackson p-jackson requested review from gmjuhasz and manzoorwanijk and removed request for gmjuhasz January 15, 2025 03:55
@p-jackson p-jackson added the Groundskeeping Worked on by Dotcom Groundskeeping label Jan 15, 2025
@p-jackson p-jackson marked this pull request as ready for review January 15, 2025 03:56
Copy link
Member

@manzoorwanijk manzoorwanijk 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 a reasonable change. Thank you for fixing it.

As you mentioned

AFAICT there isn't an existing way to check whether the site is hosted on WoA in the client, so, like Boost, we have to add something to a global. (Boost uses it's own window.Jetpack_Boost global which contains this data

There are always multiple versions of the same data passed to the client and for this reason, we decided to consolidate the initial state for Jetpack - pdWQjU-11v-p2.

So, since that flag you added is not specific to social, let us add it to some place where it can be used by other areas of the codebase.

After the suggested changes, we can have this

Screenshot 2025-01-15 at 10 09 26 AM

@@ -100,6 +100,7 @@ public static function get_admin_script_data() {
'shares_data' => array(),
'urls' => array(),
'settings' => self::get_social_settings(),
'is_woa_site' => ( new Host() )->is_woa_site(),
Copy link
Member

Choose a reason for hiding this comment

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

Instead of adding this boolean flag here, we can add it inside that set_admin_script_data method here.

if ( ! isset( $data['site']['host'] ) ) {
	$data['site']['host'] = ( new Host() )->get_known_host_guess();
}

Copy link
Member Author

Choose a reason for hiding this comment

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

By extending the JetpackScriptData interface to include the host value too, is your intention that Boost should move over to using it too? I'd be happy to make that change too, but would that be considered too much of a breaking change? (since the over-the-wire format would be changing).

In which case, would it be better to add the host value here?

Or (in keeping with the filter documentation that we should only enqueue data we know will be used) should both the Social and Boost plugins both independently add the host data in the jetpack_admin_js_script_data filter. So that when neither plugin is installed the data won't be present.

Some data is always added, whether it's used or not (like wp_version, is_multisite), but maybe those are more fundamental than the host.

Copy link
Member

Choose a reason for hiding this comment

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

By extending the JetpackScriptData interface to include the host value too, is your intention that Boost should move over to using it too? I'd be happy to make that change too, but would that be considered too much of a breaking change? (since the over-the-wire format would be changing).

I don't mean to change anything in Boost right now. I think that has been in Boost for a while. I mean to say that we just don't make that data specific to Social. Boost can later refactor to use that shared value from JetpackScriptData

In which case, would it be better to add the host value here?

That will require the status package to be a dependency for the assets package, which we don't want for this small change. At least not as a part of this PR.

Or (in keeping with the filter documentation that we should only enqueue data we know will be used) should both the Social and Boost plugins both independently add the host data in the jetpack_admin_js_script_data filter. So that when neither plugin is installed the data won't be present.

Yes, let the package that needs it, add it to the data.

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for the clarification. I'll rein in the scope of where I was starting to go with this PR 😄

@@ -54,4 +54,5 @@ export interface SocialScriptData {
store_initial_state: SocialStoreState;
supported_services: Array< ConnectionService >;
urls: SocialUrls;
is_woa_site: boolean;
Copy link
Member

Choose a reason for hiding this comment

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

After making that host data change below, we can add the host property to AdminSiteData interface.

host: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown';


return (
<div className={ styles.header }>
<span className={ styles.logo }>
<Logo />
</span>

{ ! hasSocialPaidFeatures() && (
{ ! hasSocialPaidFeatures() && ! isWoaSite && (
Copy link
Member

Choose a reason for hiding this comment

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

Then here we can use ! getScriptData().site.host !== 'woa' after

import { getScriptData } from '@automattic/jetpack-script-data';

agrullon95
agrullon95 previously approved these changes Jan 15, 2025
Copy link
Contributor

@agrullon95 agrullon95 left a comment

Choose a reason for hiding this comment

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

I tested on my atomic site and can confirm the link is no longer visible.
The link is a visible and navigating to the correct location when I tested with Jurassic NInja

@manzoorwanijk
Copy link
Member

@p-jackson Please let me know if I should make those changes for you.

@@ -18,6 +18,7 @@ export interface PublicSiteData {
export interface AdminSiteData {
admin_url: string;
date_format: string;
host: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown';
Copy link
Member

Choose a reason for hiding this comment

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

Let us make this optional as it actually is from the backend.

Suggested change
host: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown';
host?: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown';

Copy link
Member Author

Choose a reason for hiding this comment

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

In practice everything in AdminSiteData is optional since it's included in the JetpackScriptData interface using Partial< ... >.

But perhaps this makes it clearer that this property is even more optional than the other optional properties.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, thanks. I am fine with both.

manzoorwanijk
manzoorwanijk previously approved these changes Jan 15, 2025
Copy link
Member

@manzoorwanijk manzoorwanijk 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. Thank you for the fix.

I just have another optional suggestion.

Thank you for making the suggested changes.

@p-jackson
Copy link
Member Author

Thank you for making the suggested changes.

No problem, I like this better

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

This will require an Atomic release, right?

@p-jackson
Copy link
Member Author

This will require an Atomic release, right?

I don't believe so. It's not part of wpcomsh. It will just roll out whenever the stand alone Social plugin usually rolls out right? Jetpack Social is not a plugin "managed" by the Atomic platform, so it doesn't have a way of updating this plugin sooner than it coming out in the dotorg repo.

@manzoorwanijk
Copy link
Member

Yeah, makes sense. Thanks.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

Please hold off merging this. We are discussing it in our team call.

That nudge might be valid. I will get back to you on this.

Copy link
Member

@manzoorwanijk manzoorwanijk left a comment

Choose a reason for hiding this comment

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

OK, this can be shipped now. We had recently enabling purchasing of Social plans for Atomic sites and were wondering if that nudge is valid, but since they can't access the page, it's better to hide it. Sorry for keeping you waiting.

@p-jackson
Copy link
Member Author

Sounds good, thanks for the reviews!

@p-jackson p-jackson merged commit be0d34b into trunk Jan 15, 2025
76 checks passed
@p-jackson p-jackson deleted the update/social/hide-license-on-woa branch January 15, 2025 20:50
@github-actions github-actions bot removed [Status] In Progress [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Jan 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Publicize Now Jetpack Social, auto-sharing Groundskeeping Worked on by Dotcom Groundskeeping [JS Package] Publicize Components [JS Package] Script Data [Package] Publicize [Plugin] Social Issues about the Jetpack Social plugin RNA [Type] Bug When a feature is broken and / or not performing as intended
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Unable to access "Activate a Plan" link when WordPress.com interface style is enabled General Settings
3 participants