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

SPT: move storing to higher component #35618

Merged
merged 17 commits into from
Aug 21, 2019

Conversation

retrofox
Copy link
Contributor

@retrofox retrofox commented Aug 20, 2019

Changes proposed in this Pull Request

This PR move the logic which parses the template content from the <TemplateSelectorItem /> to the <PageTemplateModal />.

Right now we are processing each template content into its own component (). With processing I mean to get the raw template content (from a component property), parse this content in order to get the blocks, to finally preview them using the component.

In this PR, the templates are re-ordered as an Object which each field is the template slug. This templates property is passed to the <PageTemplateModal /> component, and once the component did mount it starts the parsing process, template by template and storing the blocks into the component state (blocks).

The blocks state is passed to the <TemplateSelectorControl /> component through of the blocksByTemplates property, and this component takes over of iterating for all templates in order to perform the preview (thumbnails).

All templates are parsed once, and also we are avoiding storing the blocks for the current preview (large preview) since now we just need the current template slug.

Related Issues: #35233

Test

Apply the patch and check that everything is working as expected.
Maybe use the developer tools to check the props and state of the components.

@retrofox retrofox requested a review from a team August 20, 2019 14:53
@matticbot
Copy link
Contributor

@matticbot
Copy link
Contributor

This PR does not affect the size of JS and CSS bundles shipped to the user's browser.

Generated by performance advisor bot at iscalypsofastyet.com.

@retrofox retrofox marked this pull request as ready for review August 20, 2019 16:12
@retrofox retrofox requested review from a team as code owners August 20, 2019 16:12
@retrofox retrofox force-pushed the try/spt-move-storing-to-higher-component branch from 190de70 to a5c6419 Compare August 20, 2019 22:41
@retrofox retrofox changed the title Try/spt move storing to higher component SPT: move storing to higher component Aug 21, 2019
Copy link
Contributor

@getdave getdave left a comment

Choose a reason for hiding this comment

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

I like what you've done here. It really improves things thank you. It's much appreciated.

I've tested manually on my local and it works as required.

One thing I've noted is that we have almost no doc blocks on our component functions. We should probably write some...

Copy link
Contributor

@marekhrabe marekhrabe left a comment

Choose a reason for hiding this comment

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

I went over the things reported in the review and they now seem to be resolved here and in the new spin-off PR. Thanks for working on it, this one is good to go!

@sirreal sirreal deleted the try/spt-move-storing-to-higher-component branch November 27, 2020 11:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants