-
Notifications
You must be signed in to change notification settings - Fork 804
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
Conversation
Are you an Automattician? Please test your changes on all WordPress.com environments to help mitigate accidental explosions.
Interested in more tips and information?
|
Thank you for your PR! When contributing to Jetpack, we have a few suggestions that can help us test and review your patch:
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:
Still unsure? Reach out in #jetpack-developers for guidance! Social plugin:
If you have any questions about the release process, please ask in the #jetpack-releases channel on Slack. |
There was a problem hiding this 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
@@ -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(), |
There was a problem hiding this comment.
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();
}
There was a problem hiding this comment.
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?
'site' => array( |
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.
There was a problem hiding this comment.
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 thehost
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 thejetpack_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.
There was a problem hiding this comment.
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; |
There was a problem hiding this comment.
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 && ( |
There was a problem hiding this comment.
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';
There was a problem hiding this 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
@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'; |
There was a problem hiding this comment.
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.
host: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown'; | |
host?: 'woa' | 'atomic' | 'newspack' | 'vip' | 'wpcom' | 'unknown'; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
No problem, I like this better |
There was a problem hiding this 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?
I don't believe so. It's not part of |
Yeah, makes sense. Thanks. |
There was a problem hiding this 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.
There was a problem hiding this 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.
Sounds good, thanks for the reviews! |
Fixes Automattic/wp-calypso#98217
Proposed changes:
is_woa_site
flag to thewindow.JetpackScriptData.social
globalAlready have an existing plan or license key?
link on the Social plugin's admin page when the site is hosted on WoAHiding 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 datajetpack/projects/plugins/boost/app/assets/src/js/lib/utils/hosting.ts
Line 16 in ee9ed01
Other information:
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.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:
/wp-admin/admin.php?page=jetpack-social
Already have an existing plan or license key?
link is hiddenjurassic.ninja
; the link should appear