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

Site Editor: Navigation templates #25739

Merged
merged 60 commits into from Oct 6, 2020
Merged

Conversation

@david-szabo97
Copy link
Member

@david-szabo97 david-szabo97 commented Sep 30, 2020

Description

A couple of things done in this PR to match the draft #23939 (comment))

  • Root menu is now Themes
  • Deleted Current Theme group
  • Deleted Current Template group
  • Templates are now in a separate menu (TemplatesMenu)
  • Template Parts are now in a separate menu (TemplatePartsMenu)
  • Page templates are now in a separate menu (TemplatesPagesMenu)
  • Post templates are now in a separate menu (TemplatesPostsMenu)
  • Moved preview panel to the root and used slot-fill (had to do this because of overflow:hidden on the Navigation component)

How has this been tested?

  • yarn wp-env start
  • Enable FSE
  • Open Site Editor
  • Click site logo to toggle the navigation sidebar

Screenshots

image
image
image

Types of changes

New feature

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • 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.
@github-actions
Copy link

@github-actions github-actions bot commented Sep 30, 2020

Size Change: +168 B (0%)

Total Size: 1.18 MB

Filename Size Change
build/annotations/index.js 3.52 kB -4 B (0%)
build/blob/index.js 668 B +48 B (7%) 🔍
build/block-directory/index.js 8.55 kB -57 B (0%)
build/block-editor/index.js 129 kB -121 B (0%)
build/block-editor/style-rtl.css 10.9 kB -16 B (0%)
build/block-editor/style.css 10.9 kB -16 B (0%)
build/block-library/editor-rtl.css 8.65 kB +42 B (0%)
build/block-library/editor.css 8.65 kB +43 B (0%)
build/block-library/index.js 135 kB +52 B (0%)
build/block-library/style-rtl.css 7.66 kB +3 B (0%)
build/block-library/style.css 7.65 kB +3 B (0%)
build/block-serialization-default-parser/index.js 1.78 kB +1 B
build/blocks/index.js 47.5 kB -3 B (0%)
build/components/index.js 169 kB +139 B (0%)
build/components/style-rtl.css 15.3 kB -63 B (0%)
build/components/style.css 15.3 kB -64 B (0%)
build/compose/index.js 9.42 kB +2 B (0%)
build/core-data/index.js 12 kB -2 B (0%)
build/data-controls/index.js 685 B -585 B (85%) 🏆
build/data/index.js 8.6 kB +189 B (2%)
build/edit-navigation/index.js 10.7 kB -2 B (0%)
build/edit-post/index.js 306 kB +251 B (0%)
build/edit-post/style-rtl.css 6.29 kB +37 B (0%)
build/edit-post/style.css 6.27 kB +38 B (0%)
build/edit-site/index.js 20.5 kB +82 B (0%)
build/edit-site/style-rtl.css 3.71 kB -67 B (1%)
build/edit-site/style.css 3.72 kB -64 B (1%)
build/edit-widgets/index.js 21.3 kB +265 B (1%)
build/editor/index.js 45.5 kB +9 B (0%)
build/editor/style-rtl.css 3.85 kB +17 B (0%)
build/editor/style.css 3.84 kB +20 B (0%)
build/element/index.js 4.44 kB +1 B
build/escape-html/index.js 734 B +1 B
build/format-library/index.js 7.49 kB -3 B (0%)
build/is-shallow-equal/index.js 710 B +1 B
build/keyboard-shortcuts/index.js 2.39 kB -4 B (0%)
build/media-utils/index.js 5.12 kB -1 B
build/nux/index.js 3.27 kB -1 B
build/plugins/index.js 2.44 kB -1 B
build/priority-queue/index.js 790 B +1 B
build/rich-text/index.js 13 kB -3 B (0%)
build/server-side-render/index.js 2.6 kB -2 B (0%)
build/shortcode/index.js 1.7 kB +1 B
build/url/index.js 4.06 kB +2 B (0%)
build/warning/index.js 1.13 kB -1 B
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 1.14 kB 0 B
build/api-fetch/index.js 3.35 kB 0 B
build/autop/index.js 2.72 kB 0 B
build/block-directory/style-rtl.css 943 B 0 B
build/block-directory/style.css 942 B 0 B
build/block-library/theme-rtl.css 741 B 0 B
build/block-library/theme.css 741 B 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/date/index.js 31.9 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 4.42 kB 0 B
build/edit-navigation/style-rtl.css 868 B 0 B
build/edit-navigation/style.css 871 B 0 B
build/edit-widgets/style-rtl.css 3 kB 0 B
build/edit-widgets/style.css 3 kB 0 B
build/editor/editor-styles-rtl.css 492 B 0 B
build/editor/editor-styles.css 493 B 0 B
build/format-library/style-rtl.css 547 B 0 B
build/format-library/style.css 548 B 0 B
build/hooks/index.js 1.74 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.54 kB 0 B
build/keycodes/index.js 1.85 kB 0 B
build/list-reusable-blocks/index.js 3.02 kB 0 B
build/list-reusable-blocks/style-rtl.css 476 B 0 B
build/list-reusable-blocks/style.css 476 B 0 B
build/notices/index.js 1.69 kB 0 B
build/nux/style-rtl.css 671 B 0 B
build/nux/style.css 668 B 0 B
build/primitives/index.js 1.34 kB 0 B
build/redux-routine/index.js 2.85 kB 0 B
build/token-list/index.js 1.24 kB 0 B
build/viewport/index.js 1.74 kB 0 B
build/wordcount/index.js 1.17 kB 0 B

compressed-size-action

@david-szabo97
Copy link
Member Author

@david-szabo97 david-szabo97 commented Sep 30, 2020

Looking forward ideas about how we should handle empty menus. For example Pages item should navigate to TemplatesPagesMenu but it's empty so we skip rendering. I wonder what would be the best way to hide the Pages item when the menu is empty. Maybe we should implement something in the Navigation component?

I'd love to see a prop like hideIfTargetMenuEmpty or something like that

#25315 already implements a similar logic for groups. It would be a bit more difficult for menus though, since we need to think about nested menus too 🤔

EDIT: Probably this wouldn't work in practice, since we might have other kind of items in the menu. So probably the best way is to create a context and store what should be visible. And nested menus.....

@david-szabo97 david-szabo97 force-pushed the add/navigation-site-editor-templates branch to 5b76047 Sep 30, 2020
@vindl
Copy link
Member

@vindl vindl commented Sep 30, 2020

Extracted Current Theme group as a separate component (CurrentTheme ; we need to come up with a better name)

I don't think we need to show this in the sidebar anymore. At least I haven't seen it in any of latest design iterations. It might make more sense in Document Settings dropdown maybe.

Also I don't think we need a Current Template section. That should be obvious from active item and title in the header?

@vindl
Copy link
Member

@vindl vindl commented Sep 30, 2020

Looking forward ideas about how we should handle empty menus. For example Pages item should navigate to TemplatesPagesMenu but it's empty so we skip rendering. I wonder what would be the best way to hide the Pages item when the menu is empty. Maybe we should implement something in the Navigation component?

It's probably fine to leave it as a placeholder for now until we add more items for it. And yes, this should be a separate issue for navigation component and not handled in this PR.

@david-szabo97
Copy link
Member Author

@david-szabo97 david-szabo97 commented Oct 1, 2020

Also I don't think we need a Current Template section. That should be obvious from active item and title in the header?

I left it there so we can overwrite templates. I think it will be replaced by the + button later 🤔

@vindl
Copy link
Member

@vindl vindl commented Oct 1, 2020

I left it there so we can overwrite templates. I think it will be replaced by the + button later 🤔

In that I case I think it's better to introduce it when we add the +/overwrite functions then?

@vindl vindl requested a review from ockham Oct 1, 2020
@vindl
Copy link
Member

@vindl vindl commented Oct 1, 2020

cc @ockham since you worked on template resolution before :)

@Copons
Copons approved these changes Oct 6, 2020
Copy link
Contributor

@Copons Copons left a comment

This works nice, thanks @david-szabo97!

I'll open two follow up issues shortly:

  • Audit and improve the performances of the new auto-draft creation.
  • Discuss with design how to handle template overwrite/revert.
@david-szabo97 david-szabo97 merged commit aae9404 into master Oct 6, 2020
15 checks passed
15 checks passed
@github-actions
Cancel Previous Runs Cancel Previous Runs
Details
@github-actions
Check Check
Details
@github-actions
build
Details
@github-actions
Admin - 1
Details
@github-actions
Compare performance with master
Details
@github-actions
pull-request-automation
Details
@github-actions
test (gutenberg-editor-gallery) test (gutenberg-editor-gallery)
Details
@github-actions
test (gutenberg-editor-gallery)
Details
@github-actions
JavaScript
Details
@github-actions
Admin - 2
Details
@github-actions
Admin - 3
Details
@github-actions
Mobile
Details
@github-actions
Admin - 4
Details
@david-szabo97 david-szabo97 deleted the add/navigation-site-editor-templates branch Oct 6, 2020
@github-actions github-actions bot added this to the Gutenberg 9.2 milestone Oct 6, 2020
Copy link
Member

@vindl vindl left a comment

Nice work @david-szabo97!

@@ -177,6 +202,13 @@ function filter_rest_wp_template_collection_params( $query_params ) {
* @return array Filtered $args.
*/
function filter_rest_wp_template_query( $args, $request ) {
// Create auto-drafts for each theme template files.
$block_template_files = gutenberg_get_template_paths();

This comment has been minimized.

@vindl

vindl Oct 6, 2020
Member

As already mentioned, accessing these files on each request is going to have a negative impact on performance. We can probably store this info once on theme activation and we'll also need it after theme updates.

// General
'front-page': {
title: 'Front page',
description: '',

This comment has been minimized.

@vindl

vindl Oct 6, 2020
Member

We could've added "Display the contents of your Front Page" here, or something along the similar lines.

This comment has been minimized.

@mcsf

mcsf Oct 7, 2020
Contributor

@david-szabo97 @vindl — Let's not forget i18n. Constants files like this should be i18n-ready from the start, otherwise getting everything ready for a testable Site Editor around WP 5.6 will be much more difficult.

This comment has been minimized.

@Copons

Copons Oct 7, 2020
Contributor

@mcsf My fault, I should have caught this in review!
I'll spin up a PR ASAP.

);

return (
<NavigationMenu

This comment has been minimized.

@vindl

vindl Oct 6, 2020
Member

We could've delayed adding this until we had actual content for it.

ockham added a commit that referenced this pull request May 21, 2021
## Description
Discovered while working on WordPress/wordpress-develop#1267.

First introduced in `lib/template-loader.php` in #25739.
No longer used per #26650 (where its callsites started using [`_gutenberg_get_template_paths`](https://github.com/WordPress/gutenberg/pull/26650/files#diff-f5b03c388f81fea69d0ababd289047e20deaad43084ad6e00ec14a5613e25136R60) in `lib/templates-sync.php` -- now in [`lib/full-site-editing/block-templates.php`](https://github.com/WordPress/gutenberg/blob/d7714aa8adf19277da1f0ea83b20be1cf234e50c/lib/full-site-editing/block-templates.php#L17)).
stacimc added a commit to stacimc/gutenberg that referenced this pull request May 25, 2021
…ess#32066)

## Description
Discovered while working on WordPress/wordpress-develop#1267.

First introduced in `lib/template-loader.php` in WordPress#25739.
No longer used per WordPress#26650 (where its callsites started using [`_gutenberg_get_template_paths`](https://github.com/WordPress/gutenberg/pull/26650/files#diff-f5b03c388f81fea69d0ababd289047e20deaad43084ad6e00ec14a5613e25136R60) in `lib/templates-sync.php` -- now in [`lib/full-site-editing/block-templates.php`](https://github.com/WordPress/gutenberg/blob/d7714aa8adf19277da1f0ea83b20be1cf234e50c/lib/full-site-editing/block-templates.php#L17)).
getdave added a commit that referenced this pull request May 27, 2021
## Description
Discovered while working on WordPress/wordpress-develop#1267.

First introduced in `lib/template-loader.php` in #25739.
No longer used per #26650 (where its callsites started using [`_gutenberg_get_template_paths`](https://github.com/WordPress/gutenberg/pull/26650/files#diff-f5b03c388f81fea69d0ababd289047e20deaad43084ad6e00ec14a5613e25136R60) in `lib/templates-sync.php` -- now in [`lib/full-site-editing/block-templates.php`](https://github.com/WordPress/gutenberg/blob/d7714aa8adf19277da1f0ea83b20be1cf234e50c/lib/full-site-editing/block-templates.php#L17)).
vcanales added a commit that referenced this pull request Jul 7, 2021
## Description
Discovered while working on WordPress/wordpress-develop#1267.

First introduced in `lib/template-loader.php` in #25739.
No longer used per #26650 (where its callsites started using [`_gutenberg_get_template_paths`](https://github.com/WordPress/gutenberg/pull/26650/files#diff-f5b03c388f81fea69d0ababd289047e20deaad43084ad6e00ec14a5613e25136R60) in `lib/templates-sync.php` -- now in [`lib/full-site-editing/block-templates.php`](https://github.com/WordPress/gutenberg/blob/d7714aa8adf19277da1f0ea83b20be1cf234e50c/lib/full-site-editing/block-templates.php#L17)).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment