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

Add template list preloading for users, themes and plugins #36901

Closed
wants to merge 2 commits into from

Conversation

talldan
Copy link
Contributor

@talldan talldan commented Nov 26, 2021

Description

Adds preloading for some of the requests made in the site editor template list.

This builds on #36763. I've separated it out because it wasn't easy. I think the code is complex enough to question whether it's worth doing this.

Most of the complexity comes from the fact that a REST request is required to get the data needed to preload user, theme and plugin details that are displayed in the Added By column.

Better solutions to this would be server side rendering of the page or using something like GraphQL to fetch all the required info in one go.

How has this been tested?

  1. Open the site editor
  2. Go to Templates or Template Parts in the navigation sidebar.
  3. Data in the Added By column should load straight away (apart from images, which naturally take some time)
  4. Check the network tab in the dev tools, there should be any requests for users, themes or plugins
  5. Visit http://localhost:8889/wp-admin/themes.php?page=gutenberg-edit-site&postType=post (make sure you have some posts first
  6. The author name should load straight away.

Types of changes

Enhancement

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • I've tested my changes with keyboard and screen readers.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@talldan talldan added [Type] Enhancement A suggestion for improvement. [Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") labels Nov 26, 2021
@talldan talldan self-assigned this Nov 26, 2021
@talldan talldan force-pushed the update/added-by-in-templates-list branch from e7c055f to fdde4c8 Compare November 29, 2021 01:25
@talldan talldan requested a review from nerrad as a code owner November 29, 2021 01:25
Base automatically changed from update/added-by-in-templates-list to trunk November 29, 2021 03:43
@Mamaduka
Copy link
Member

@talldan, Maybe we should start with a more minimalist approach.

  • Only preload data for an active theme. Currently, the template list will only display templates for it.
  • Ignore plugins for now. This feature isn't documented, and we can recommend plugins to add their preload paths.

Better solutions to this would be server side rendering of the page or using something like GraphQL to fetch all the required info in one go.

We could use Embedding for this - https://developer.wordpress.org/rest-api/using-the-rest-api/linking-and-embedding/#embedding

@talldan
Copy link
Contributor Author

talldan commented Nov 29, 2021

We could use Embedding for this - https://developer.wordpress.org/rest-api/using-the-rest-api/linking-and-embedding/#embedding

@noisysocks just also mentioned this to me. I wasn't aware of this feature. I think it would be a good thing to look into. I'll put this on pause and look at alternatives.

@talldan
Copy link
Contributor Author

talldan commented Dec 3, 2021

I had a go at adding embeds to the templates controller and it works pretty well - WordPress/wordpress-develop#2002.

Here's an example of the theme data being embeded in the response of a template:
Screen Shot 2021-12-03 at 5 51 47 pm

I need to work on the Gutenberg side of this as well.

My take on it is that it's pretty firmly in the enhancement territory so I don't know about landing this for 5.9, but I'll continue chipping away at this task.

@talldan talldan closed this Jun 23, 2023
@talldan talldan deleted the add/template-list-preloading branch June 23, 2023 06:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] Site Editor Related to the overarching Site Editor (formerly "full site editing") [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants