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

Full Site Editing: add a is_fse_active property to the Site object in the REST API #13196

Merged
merged 4 commits into from Aug 26, 2019

Conversation

jeherve
Copy link
Member

@jeherve jeherve commented Aug 7, 2019

Changes proposed in this Pull Request:

Adding a property to the Site object since 1. the blog-stickers endpoint is only for automattians, and 2. to avoid duplicating theme support logic on the backend and in Calypso

Also introduce the wpcom_is_full_site_editing_active function and use it to hide the Customizer menu in wp-admin

Reviewers: #cylon_team, #serenity_team, helpingcat

Reviewed By: #serenity_team, helpingcat

Subscribers: helpingcat

Tags: #touches_jetpack_files

Differential Revision: D31148-code, D31319-code

This commit syncs r194971-wpcom and r195033-wpcom.

Testing instructions:

Instructions in Automattic/wp-calypso#35106

also: the Customizer menu link should likewise be hidden under the same circumstance in wp-admin

Proposed changelog entry for your changes:

  • WordPress.com API: add option to manage Full Site Editing.

@jeherve jeherve added this to the 7.7 milestone Aug 7, 2019
@jeherve jeherve requested a review from a team as a code owner August 7, 2019 06:45
@jetpackbot
Copy link

jetpackbot commented Aug 7, 2019

Warnings
⚠️

pre-commit hook was skipped for one or more commits

This is an automated check which relies on PULL_REQUEST_TEMPLATE. We encourage you to follow that template as it helps Jetpack maintainers do their job. If you think 'Testing instructions' or 'Proposed changelog entry' are not needed for your PR - please explain why you think so. Thanks for cooperation 🤖

Generated by 🚫 dangerJS against 2bf46e2

@jeherve jeherve added [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Aug 7, 2019
@jeherve
Copy link
Member Author

jeherve commented Aug 7, 2019

@mattwiebe Would we need to edit sal/class.json-api-site-base.php as well to add the new is_fse_active function there?

@mattwiebe
Copy link
Contributor

Would we need to edit sal/class.json-api-site-base.php as well to add the new is_fse_active function there?

I'm not certain, possibly? MY SAL-fu is weak. We're going to need to detect this on the JP site's side via having the FSE plugin (full-site-editing/full-site-editing.php I believe) active, and likely also a supported theme. That should be detectable via current_theme_supports( 'full-site-editing' ).

@jeherve
Copy link
Member Author

jeherve commented Aug 7, 2019

Alright, thanks for the explanation. I can't seem to be able to get the Customizer link to disappear, even on a WordPress.com site, so I am probably not the best person to keep looking into this. :)

I'll let y'all figure this out as you keep working on this and add the conditions you've mentioned for Jetpack sites.

@mattwiebe
Copy link
Contributor

Yup we'll figure it out, thanks for the ping. :)

@noahtallen
Copy link
Member

What should our next steps be here in terms of testing? Since that other PR has landed, is there something different we are testing here?

@gwwar
Copy link
Contributor

gwwar commented Aug 19, 2019

I need to walk though these steps, but for reviewers I think this can be tested with the following

Screen Shot 2019-08-19 at 5 35 33 PM

Screen Shot 2019-08-19 at 5 35 14 PM

- Requests to site APIs should default to remote, so I think then all we need to do is verify that we see the new property on the wpcom sites response.

Screen Shot 2019-08-19 at 2 47 20 PM

@gwwar
Copy link
Contributor

gwwar commented Aug 20, 2019

So I'm seeing the following behavior:

Single Site Request

A 400 when we forward to the remote site in a
/sites/{site} request:

Screen Shot 2019-08-19 at 5 40 11 PM

Screen Shot 2019-08-19 at 5 22 10 PM 1

@jeherve should I not be testing with Jurassic Ninja here, or should it work? I've connected the site.

@mattwiebe would it be possible to please check for server errors here?

All Sites

On /me/sites we use cached site data on WordPress.com and don't request information from the remote. Here, we see the new is_fse_active property but this is always false, even with all the steps above.

Screen Shot 2019-08-19 at 5 21 16 PM

@mattwiebe any other steps to follow? Maybe I need to simulate an Atomic site here?

@gwwar
Copy link
Contributor

gwwar commented Aug 20, 2019

I wonder if there is a difference here between theme names, eg "pub/modern-business" and "modern-business" on the whitelist checks.

@jeherve
Copy link
Member Author

jeherve commented Aug 20, 2019

A 400 when we forward to the remote site in a /sites/{site} request
should I not be testing with Jurassic Ninja here, or should it work? I've connected the site.

It should work with any site really, JN or an Atomic site. However, as you can see in the error message you get a 500 error from the site. I assume this is because of this:
#13196 (comment)

Once you add this function to sal/class.json-api-site-base.php, you should see is_fse_active in the response from the API, and it will return whatever you've set in your function.

On /me/sites we use cached site data on WordPress.com and don't request information from the remote. Here, we see the new is_fse_active property but this is always false

I believe that's to be expected, since that's the value that's currently returned in public.api/rest/sal/class.json-api-site-jetpack-shadow.php.

I wonder if there is a difference here between theme names, eg "pub/modern-business" and "modern-business" on the whitelist checks.

This would definitely have an impact. If you install a theme from WordPress.com on a Jetpack site, from the Themes screen in Calypso, it will have a slug like modern-business-wpcom. You would have to take that into account in your checks.

@jeherve jeherve removed this from the 7.7 milestone Aug 21, 2019
@mattwiebe
Copy link
Contributor

Had some fun last week with deploy fatals but I'm circling back to this :)

@mattwiebe
Copy link
Contributor

Ok, 223c5c7268966b607898826e69d2c56f3510a573 should get the job done. I don't know if this has made a mess of sync @jeherve, please let me know if there's a more preferred way of doing this. :)

@gwwar
Copy link
Contributor

gwwar commented Aug 21, 2019

If the files are already whitelisted, I think the whole fusion dance is happier starting from a Jetpack PR, which then creates the diff/updates it.

@gwwar
Copy link
Contributor

gwwar commented Aug 21, 2019

Still getting a 400 on the single site endpoint and false for me/sites. There might be a separate issues to work on for getting this value to be true, in the right cases for Jetpack sites.

@mattwiebe
Copy link
Contributor

Hmm I definitely don't get a 400 on a single site endpoint with this branch active, but D31808-code should take care of /me/sites.

Copy link
Member Author

@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.

I don't know if this has made a mess of sync @jeherve

You should be all good on that front 👍.

  • /me/sites and /me/site/%s work well for me now, when I am sandboxed with D31808-code applied. They both return true for is_fse_active.
  • I still see the Customize link in Calypso. That seems like a bug, or maybe I am missing something.
  • If I try to edit a page, I get the full site editing experience.

Nitpicking and not blocking, but a few minor changes would help us get rid of PHPCS warnings here:

diff --git a/sal/class.json-api-site-jetpack.php b/sal/class.json-api-site-jetpack.php
index 0af76af2a..f13fbbd88 100644
--- a/sal/class.json-api-site-jetpack.php
+++ b/sal/class.json-api-site-jetpack.php
@@ -189,10 +189,11 @@ class Jetpack_Site extends Abstract_Jetpack_Site {
 
 	function is_fse_active() {
 		$fse_enabled = is_plugin_active( 'full-site-editing/full-site-editing-plugin.php' );
-		$has_method = method_exists( '\A8C\FSE\Full_Site_Editing', 'is_supported_theme' );
+		$has_method  = method_exists( '\A8C\FSE\Full_Site_Editing', 'is_supported_theme' );
 		if ( $fse_enabled && $has_method ) {
-			$fse = \A8C\FSE\Full_Site_Editing::get_instance();
+			$fse  = \A8C\FSE\Full_Site_Editing::get_instance();
 			$slug = get_option( 'stylesheet' );
+
 			return $fse->is_supported_theme( $slug );
 		}
 		return false;

sal/class.json-api-site-jetpack.php Outdated Show resolved Hide resolved
@mattwiebe
Copy link
Contributor

mattwiebe commented Aug 22, 2019

I still see the Customize link in Calypso. That seems like a bug, or maybe I am missing something.

Hmm yeah, as long as we get a true response from the API, we should be able to fix things on the Calypso side. Shouldn't block this.

Anyway both your suggestions have landed @jeherve

Copy link
Member Author

@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.

LGTM now. 👍 I'll let someone else review; I can't approve on my own since I created the PR :)

@jeherve jeherve added [Status] Needs Review To request a review from Crew. Label will be renamed soon. and removed [Status] Needs Author Reply We would need you to make some changes or provide some more details about your PR. Thank you! labels Aug 22, 2019
@jeherve jeherve added this to the 7.7 milestone Aug 22, 2019
@gwwar
Copy link
Contributor

gwwar commented Aug 23, 2019

🤔 Maybe just something with my setup then I'm still seeing 400s. @mattwiebe maybe add a screenshot of a good response, and ✅ on the review?

@mattwiebe
Copy link
Contributor

Here's a good response from my Jetpack site with this PR checked out:

image

@gwwar
Copy link
Contributor

gwwar commented Aug 23, 2019

Go ahead and approve then @mattwiebe, I can see if we can get a +1 on manual testing, but I think this is probably okay

mattwiebe
mattwiebe previously approved these changes Aug 23, 2019
Copy link
Contributor

@mattwiebe mattwiebe left a comment

Choose a reason for hiding this comment

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

Looks like @jeherve needs someone else from Automattic/jetpack-crew to approve but I'm happy with it :)

oskosk
oskosk previously approved these changes Aug 26, 2019
Copy link
Contributor

@oskosk oskosk left a comment

Choose a reason for hiding this comment

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

LGTM

@oskosk oskosk added [Status] Ready to Merge Go ahead, you can push that green button! and removed [Status] Needs Review To request a review from Crew. Label will be renamed soon. labels Aug 26, 2019
…in the REST API

Summary:
Adding a property to the Site object since 1. the blog-stickers endpoint is only for automattians, and 2. to avoid duplicating theme support logic on the backend and in Calypso

Also introduce the `wpcom_is_full_site_editing_active` function and use it to hide the Customizer menu in wp-admin

Test Plan:
instructions in Automattic/wp-calypso#35106

also: the Customizer menu link should likewise be hidden under the same circumstance in wp-admin

Reviewers: #cylon_team, #serenity_team, helpingcat

Reviewed By: #serenity_team, helpingcat

Subscribers: helpingcat

Tags: #touches_jetpack_files

Differential Revision: D31148-code

This commit syncs r194971-wpcom.
… is populated on the `/rest/v1.2/sites/SITE` endpoint

Summary: Should have been included in D31148 for completeness but the bug wasn't exposed due to only testing on `/me/sites`

Test Plan: TC Tests, REST API console

Reviewers: #cylon_team, vindl

Reviewed By: #cylon_team, vindl

Tags: #touches_jetpack_files

Differential Revision: D31319-code

This commit syncs r195033-wpcom.
* check if FSE is active
* also check if the theme is supported
@jeherve jeherve dismissed stale reviews from oskosk and mattwiebe via 2bf46e2 August 26, 2019 11:27
@jeherve jeherve force-pushed the fusion-sync/jeherve/r194971-wpcom-1565160115 branch from b43ab7e to 2bf46e2 Compare August 26, 2019 11:27
@jeherve jeherve merged commit 9f9bb82 into master Aug 26, 2019
@jeherve jeherve deleted the fusion-sync/jeherve/r194971-wpcom-1565160115 branch August 26, 2019 11:39
@matticbot matticbot added [Status] Needs Changelog and removed [Status] Ready to Merge Go ahead, you can push that green button! labels Aug 26, 2019
jeherve added a commit that referenced this pull request Aug 26, 2019
jeherve added a commit that referenced this pull request Aug 27, 2019
* 7.7 changelog: initial set of changes

* Changelog: add #13154

* Changelog: add #13134

* Changelog: add #12699 and many others

* Changelog: add #13127

* Changelog: add #13167

* Changelog: add #13225

* Changelog: add #13179

* Changelog: add #13173

* Changelog: add #13232

* Changelog: add #13137

* Changelog: add #13172

* Changelog: add #13182

* Changelog: add #13200

* Changelog: add #13244

* Changelog: add #13267

* Changelog: add #13204

* changelog: add #13205

* Changelog: add #13183

* Changelog: add #13278

* Changelog: add #13162

* Changelog: add #13268

* Changelog: add #13286

* Changelog: add #13273

* Changelog: add #12474

* Changelog: add #13085

* Changelog: add #13266

* Changelog: add #13306

* Changelog: add #13311

* Changelog: add #13302

* Changelog: add #13196

* Changelog: add #12733

* Changelog: add #13261

* Changelog: add #13322

* Changelog: add #13333

* Changelog: add #13335
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.

None yet

7 participants