From 9e59f77f557f9217c74f909a94f42091bd710341 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 14:05:06 +0200 Subject: [PATCH 01/37] Details page for parts: always go back to patterns --- .../sidebar-navigation-screen-pattern/index.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index 8607dad09241cf..881413390987d4 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -4,7 +4,6 @@ import { useDispatch } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { pencil } from '@wordpress/icons'; -import { getQueryArgs } from '@wordpress/url'; import { privateApis as routerPrivateApis } from '@wordpress/router'; /** @@ -17,7 +16,6 @@ import usePatternDetails from './use-pattern-details'; import { store as editSiteStore } from '../../store'; import { unlock } from '../../lock-unlock'; import TemplateActions from '../template-actions'; -import { TEMPLATE_PART_POST_TYPE } from '../../utils/constants'; const { useLocation, useHistory } = unlock( routerPrivateApis ); @@ -27,20 +25,12 @@ export default function SidebarNavigationScreenPattern() { const { params: { postType, postId }, } = location; - const { categoryType } = getQueryArgs( window.location.href ); const { setCanvasMode } = unlock( useDispatch( editSiteStore ) ); useInitEditedEntityFromURL(); const patternDetails = usePatternDetails( postType, postId ); - - // The absence of a category type in the query params for template parts - // indicates the user has arrived at the template part via the "manage all" - // page and the back button should return them to that list page. - const backPath = - ! categoryType && postType === TEMPLATE_PART_POST_TYPE - ? { path: '/wp_template_part/all' } - : { path: '/patterns' }; + const backPath = '/patterns'; return ( Date: Thu, 11 Apr 2024 20:16:27 +0200 Subject: [PATCH 02/37] Remove wp_template_part/all sidebar --- .../sidebar-navigation-screen-templates-browse/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js index 04774f081163df..0f9d04332e7b6d 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js @@ -10,10 +10,7 @@ import { privateApis as routerPrivateApis } from '@wordpress/router'; */ import SidebarNavigationScreen from '../sidebar-navigation-screen'; import { store as editSiteStore } from '../../store'; -import { - TEMPLATE_POST_TYPE, - TEMPLATE_PART_POST_TYPE, -} from '../../utils/constants'; +import { TEMPLATE_POST_TYPE } from '../../utils/constants'; import { unlock } from '../../lock-unlock'; import DataviewsTemplatesSidebarContent from './content'; From de0226a3128e9d30ecbf3fe2d9f17238b8deed6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:17:24 +0200 Subject: [PATCH 03/37] Remove wp_template_part/all content & preview frames --- .../edit-site/src/components/layout/router.js | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index 96354d809bd835..f94ee5cbc809bf 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -131,35 +131,6 @@ export default function useLayoutAreas() { }; } - // Template parts - if ( path === '/wp_template_part/all' ) { - const isListLayout = isCustom !== 'true' && layout === 'list'; - return { - key: 'template-parts', - areas: { - sidebar: ( - - ), - content: ( - - ), - preview: isListLayout && ( - - ), - mobile: ( - - ), - }, - widths: { - content: isListLayout ? 380 : undefined, - }, - }; - } - // Patterns if ( path === '/patterns' ) { return { From 943ac6ce0d72eade2cff3a75b96268b5b34f5067 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:18:40 +0200 Subject: [PATCH 04/37] Remove code to sync entity from URL params --- .../sync-state-with-url/use-init-edited-entity-from-url.js | 4 ---- 1 file changed, 4 deletions(-) diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index 8cfb0bca716f2f..1f9d71945f76cf 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -226,10 +226,6 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) { return { isReady: true, postType: 'wp_template', postId, context }; } - if ( path === '/wp_template_part/all' && postId ) { - return { isReady: true, postType: 'wp_template_part', postId, context }; - } - if ( postTypesWithoutParentTemplate.includes( postType ) ) { return { isReady: true, postType, postId, context }; } From c08064e174a7ac290c8975efd3290676f19233f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:19:39 +0200 Subject: [PATCH 05/37] wp_template_part/all is no longer a page that exists --- packages/edit-site/src/utils/get-is-list-page.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/packages/edit-site/src/utils/get-is-list-page.js b/packages/edit-site/src/utils/get-is-list-page.js index 0fa818c28cb510..f7312ec3c1c292 100644 --- a/packages/edit-site/src/utils/get-is-list-page.js +++ b/packages/edit-site/src/utils/get-is-list-page.js @@ -14,9 +14,7 @@ export default function getIsListPage( isMobileViewport ) { return ( - [ '/wp_template', '/wp_template_part/all', '/pages' ].includes( - path - ) || + [ '/wp_template', '/pages' ].includes( path ) || ( path === '/patterns' && // Don't treat "/patterns" without categoryType and categoryId as a // list page in mobile because the sidebar covers the whole page. From d3e095e3ec2a1f5fa342c90ea1b003f8321f4271 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:22:44 +0200 Subject: [PATCH 06/37] Remove link to Manage all Parts --- .../index.js | 28 ------------------- 1 file changed, 28 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index cb823422480a0a..fc7e49d85aebf3 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -5,7 +5,6 @@ import { __experimentalItemGroup as ItemGroup, __experimentalItem as Item, } from '@wordpress/components'; -import { useViewportMatch } from '@wordpress/compose'; import { getTemplatePartIcon } from '@wordpress/editor'; import { __ } from '@wordpress/i18n'; import { getQueryArgs } from '@wordpress/url'; @@ -17,7 +16,6 @@ import { file } from '@wordpress/icons'; * Internal dependencies */ import AddNewPattern from '../add-new-pattern'; -import SidebarNavigationItem from '../sidebar-navigation-item'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import CategoryItem from './category-item'; import { @@ -25,10 +23,8 @@ import { PATTERN_TYPES, TEMPLATE_PART_POST_TYPE, } from '../../utils/constants'; -import { useLink } from '../routes/link'; import usePatternCategories from './use-pattern-categories'; import useTemplatePartAreas from './use-template-part-areas'; -import { store as editSiteStore } from '../../store'; function CategoriesGroup( { templatePartAreas, @@ -106,7 +102,6 @@ function CategoriesGroup( { } export default function SidebarNavigationScreenPatterns() { - const isMobileViewport = useViewportMatch( 'medium', '<' ); const { categoryType, categoryId } = getQueryArgs( window.location.href ); const currentCategory = categoryId || PATTERN_DEFAULT_CATEGORY; const currentType = categoryType || PATTERN_TYPES.theme; @@ -118,28 +113,6 @@ export default function SidebarNavigationScreenPatterns() { ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme, [] ); - const isTemplatePartsMode = useSelect( ( select ) => { - const settings = select( editSiteStore ).getSettings(); - return !! settings.supportsTemplatePartsMode; - }, [] ); - - const templatePartsLink = useLink( { - path: '/wp_template_part/all', - // If a classic theme that supports template parts accessed - // the Patterns page directly, preserve that state in the URL. - didAccessPatternsPage: - ! isBlockBasedTheme && isTemplatePartsMode ? 1 : undefined, - } ); - - const footer = ! isMobileViewport ? ( - - { ( isBlockBasedTheme || isTemplatePartsMode ) && ( - - { __( 'Manage all template parts' ) } - - ) } - - ) : undefined; return ( } - footer={ footer } content={ <> { isLoading && __( 'Loading patterns…' ) } From 9c628070b9c7beb638cf9836b74d179b201b76bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 20:55:31 +0200 Subject: [PATCH 07/37] Remove code for Parts in the Templates component --- .../edit-site/src/components/layout/router.js | 10 +-- .../add-new-template-part.js | 62 ----------------- .../page-templates-template-parts/index.js | 67 +++++++------------ 3 files changed, 25 insertions(+), 114 deletions(-) delete mode 100644 packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index f94ee5cbc809bf..7c1d6dd818c0fc 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -112,18 +112,12 @@ export default function useLayoutAreas() { ), content: ( - + ), preview: isListLayout && ( ), - mobile: ( - - ), + mobile: , }, widths: { content: isListLayout ? 380 : undefined, diff --git a/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js b/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js deleted file mode 100644 index 2a7bbda971013a..00000000000000 --- a/packages/edit-site/src/components/page-templates-template-parts/add-new-template-part.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * WordPress dependencies - */ -import { privateApis as routerPrivateApis } from '@wordpress/router'; -import { useSelect } from '@wordpress/data'; -import { store as coreStore } from '@wordpress/core-data'; -import { useState, memo } from '@wordpress/element'; -import { Button } from '@wordpress/components'; - -/** - * Internal dependencies - */ -import { unlock } from '../../lock-unlock'; -import { store as editSiteStore } from '../../store'; -import CreateTemplatePartModal from '../create-template-part-modal'; -import { TEMPLATE_PART_POST_TYPE } from '../../utils/constants'; - -const { useHistory } = unlock( routerPrivateApis ); - -function AddNewTemplatePart() { - const { canCreate, postType } = useSelect( ( select ) => { - const { supportsTemplatePartsMode } = - select( editSiteStore ).getSettings(); - return { - canCreate: ! supportsTemplatePartsMode, - postType: select( coreStore ).getPostType( - TEMPLATE_PART_POST_TYPE - ), - }; - }, [] ); - const [ isModalOpen, setIsModalOpen ] = useState( false ); - const history = useHistory(); - - if ( ! canCreate || ! postType ) { - return null; - } - - return ( - <> - - { isModalOpen && ( - setIsModalOpen( false ) } - blocks={ [] } - onCreate={ ( templatePart ) => { - setIsModalOpen( false ); - history.push( { - postId: templatePart.id, - postType: TEMPLATE_PART_POST_TYPE, - canvas: 'edit', - } ); - } } - onError={ () => setIsModalOpen( false ) } - /> - ) } - - ); -} - -export default memo( AddNewTemplatePart ); diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates-template-parts/index.js index fabcb0a6412186..e88be445570988 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates-template-parts/index.js @@ -44,7 +44,6 @@ import { import usePatternSettings from '../page-patterns/use-pattern-settings'; import { unlock } from '../../lock-unlock'; -import AddNewTemplatePart from './add-new-template-part'; const { usePostActions } = unlock( editorPrivateApis ); @@ -175,10 +174,7 @@ function Preview( { item, viewType } ) { onClick={ onClick } aria-label={ item.title?.rendered || item.title } > - { isEmpty && - ( item.type === TEMPLATE_POST_TYPE - ? __( 'Empty template' ) - : __( 'Empty template part' ) ) } + { isEmpty && __( 'Empty template' ) } { ! isEmpty && ( @@ -199,7 +195,7 @@ const TEMPLATE_ACTIONS = [ 'delete-template', ]; -export default function PageTemplatesTemplateParts( { postType } ) { +export default function PageTemplatesTemplateParts() { const { params } = useLocation(); const { activeView = 'all', layout } = params; const defaultView = useMemo( () => { @@ -239,7 +235,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { const { records, isResolving: isLoadingData } = useEntityRecords( 'postType', - postType, + TEMPLATE_POST_TYPE, { per_page: -1, } @@ -271,8 +267,8 @@ export default function PageTemplatesTemplateParts( { postType } ) { } ) ); }, [ records ] ); - const fields = useMemo( () => { - const _fields = [ + const fields = useMemo( + () => [ { header: __( 'Preview' ), id: 'preview', @@ -284,10 +280,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { enableSorting: false, }, { - header: - postType === TEMPLATE_POST_TYPE - ? __( 'Template' ) - : __( 'Template Part' ), + header: __( 'Template' ), id: 'title', getValue: ( { item } ) => item.title?.rendered, render: ( { item } ) => ( @@ -297,9 +290,7 @@ export default function PageTemplatesTemplateParts( { postType } ) { enableHiding: false, enableGlobalSearch: true, }, - ]; - if ( postType === TEMPLATE_POST_TYPE ) { - _fields.push( { + { header: __( 'Description' ), id: 'description', render: ( { item } ) => { @@ -324,23 +315,21 @@ export default function PageTemplatesTemplateParts( { postType } ) { minWidth: 320, enableSorting: false, enableGlobalSearch: true, - } ); - } - // TODO: The plan is to support fields reordering, which would require an API like `order` or something - // similar. With the aforementioned API we wouldn't need to construct the fields array like this. - _fields.push( { - header: __( 'Author' ), - id: 'author', - getValue: ( { item } ) => item.author_text, - render: ( { item } ) => { - return ; }, - type: ENUMERATION_TYPE, - elements: authors, - width: '1%', - } ); - return _fields; - }, [ postType, authors, view.type ] ); + { + header: __( 'Author' ), + id: 'author', + getValue: ( { item } ) => item.author_text, + render: ( { item } ) => { + return ; + }, + type: ENUMERATION_TYPE, + elements: authors, + width: '1%', + }, + ], + [ authors, view.type ] + ); const { data, paginationInfo } = useMemo( () => { return filterSortAndPaginate( records, view, fields ); @@ -386,18 +375,8 @@ export default function PageTemplatesTemplateParts( { postType } ) { return ( - ) : ( - - ) - } + title={ __( 'Templates' ) } + actions={ } > Date: Thu, 11 Apr 2024 20:58:05 +0200 Subject: [PATCH 08/37] Rename page class: from edit-site-page-template-template-parts-dataviews to edit-site-page-templates --- .../src/components/page-templates-template-parts/index.js | 2 +- .../src/components/page-templates-template-parts/style.scss | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates-template-parts/index.js index e88be445570988..e3590354012c9e 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates-template-parts/index.js @@ -374,7 +374,7 @@ export default function PageTemplatesTemplateParts() { return ( } > diff --git a/packages/edit-site/src/components/page-templates-template-parts/style.scss b/packages/edit-site/src/components/page-templates-template-parts/style.scss index 79c999e50acdf7..aae65680d2f53f 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/style.scss +++ b/packages/edit-site/src/components/page-templates-template-parts/style.scss @@ -59,7 +59,7 @@ white-space: normal; } -.edit-site-page-template-template-parts-dataviews { +.edit-site-page-templates { .dataviews-pagination { z-index: z-index(".edit-site-templates__dataviews-list-pagination"); } From 4d29772a9fe9db55862ba2223fe3c067eca408f7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 11 Apr 2024 21:00:20 +0200 Subject: [PATCH 09/37] Move page-templates-template-parts to page-templates --- packages/edit-site/src/components/layout/router.js | 9 +++------ packages/edit-site/src/components/page-patterns/index.js | 2 +- .../hooks.js | 0 .../index.js | 2 +- .../style.scss | 0 .../use-pattern-details.js | 2 +- .../sidebar-navigation-screen-template/index.js | 2 +- .../content.js | 2 +- packages/edit-site/src/style.scss | 2 +- 9 files changed, 9 insertions(+), 12 deletions(-) rename packages/edit-site/src/components/{page-templates-template-parts => page-templates}/hooks.js (100%) rename packages/edit-site/src/components/{page-templates-template-parts => page-templates}/index.js (99%) rename packages/edit-site/src/components/{page-templates-template-parts => page-templates}/style.scss (100%) diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index 7c1d6dd818c0fc..d46e65ff54b336 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -12,6 +12,7 @@ import { useIsSiteEditorLoading } from './hooks'; import Editor from '../editor'; import PagePages from '../page-pages'; import PagePatterns from '../page-patterns'; +import PageTemplates from '../page-templates'; import PageTemplatesTemplateParts from '../page-templates-template-parts'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles'; @@ -24,10 +25,6 @@ import SidebarNavigationScreenPattern from '../sidebar-navigation-screen-pattern import SidebarNavigationScreenPatterns from '../sidebar-navigation-screen-patterns'; import SidebarNavigationScreenNavigationMenu from '../sidebar-navigation-screen-navigation-menu'; import DataViewsSidebarContent from '../sidebar-dataviews'; -import { - TEMPLATE_POST_TYPE, - TEMPLATE_PART_POST_TYPE, -} from '../../utils/constants'; const { useLocation, useHistory } = unlock( routerPrivateApis ); @@ -112,12 +109,12 @@ export default function useLayoutAreas() { ), content: ( - + ), preview: isListLayout && ( ), - mobile: , + mobile: , }, widths: { content: isListLayout ? 380 : undefined, diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index 1f8521071530cc..063632c493822b 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -68,7 +68,7 @@ import { unlock } from '../../lock-unlock'; import usePatterns from './use-patterns'; import PatternsHeader from './header'; import { useLink } from '../routes/link'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; const { ExperimentalBlockEditorProvider, useGlobalStyle } = unlock( blockEditorPrivateApis diff --git a/packages/edit-site/src/components/page-templates-template-parts/hooks.js b/packages/edit-site/src/components/page-templates/hooks.js similarity index 100% rename from packages/edit-site/src/components/page-templates-template-parts/hooks.js rename to packages/edit-site/src/components/page-templates/hooks.js diff --git a/packages/edit-site/src/components/page-templates-template-parts/index.js b/packages/edit-site/src/components/page-templates/index.js similarity index 99% rename from packages/edit-site/src/components/page-templates-template-parts/index.js rename to packages/edit-site/src/components/page-templates/index.js index e3590354012c9e..a64cb63cfbc8c4 100644 --- a/packages/edit-site/src/components/page-templates-template-parts/index.js +++ b/packages/edit-site/src/components/page-templates/index.js @@ -195,7 +195,7 @@ const TEMPLATE_ACTIONS = [ 'delete-template', ]; -export default function PageTemplatesTemplateParts() { +export default function PageTemplates() { const { params } = useLocation(); const { activeView = 'all', layout } = params; const defaultView = useMemo( () => { diff --git a/packages/edit-site/src/components/page-templates-template-parts/style.scss b/packages/edit-site/src/components/page-templates/style.scss similarity index 100% rename from packages/edit-site/src/components/page-templates-template-parts/style.scss rename to packages/edit-site/src/components/page-templates/style.scss diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js index 3c88da7990e1ae..dfdfbd87d22008 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/use-pattern-details.js @@ -14,7 +14,7 @@ import { useSelect } from '@wordpress/data'; /** * Internal dependencies */ -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import useEditedEntityRecord from '../use-edited-entity-record'; import useNavigationMenuContent from './use-navigation-menu-content'; import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer'; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js index 1ab45a1566cea0..ff12434b278952 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-template/index.js @@ -17,7 +17,7 @@ import useEditedEntityRecord from '../use-edited-entity-record'; import { unlock } from '../../lock-unlock'; import { store as editSiteStore } from '../../store'; import SidebarButton from '../sidebar-button'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import TemplateActions from '../template-actions'; import HomeTemplateDetails from './home-template-details'; import SidebarNavigationScreenDetailsFooter from '../sidebar-navigation-screen-details-footer'; diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js index dd7d8dc507873d..7e69f4c60c5a8d 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js @@ -9,7 +9,7 @@ import { __experimentalItemGroup as ItemGroup } from '@wordpress/components'; * Internal dependencies */ import DataViewItem from '../sidebar-dataviews/dataview-item'; -import { useAddedBy } from '../page-templates-template-parts/hooks'; +import { useAddedBy } from '../page-templates/hooks'; import { layout } from '@wordpress/icons'; const EMPTY_ARRAY = []; diff --git a/packages/edit-site/src/style.scss b/packages/edit-site/src/style.scss index 32ad64f34fb514..96b8271b25552a 100644 --- a/packages/edit-site/src/style.scss +++ b/packages/edit-site/src/style.scss @@ -10,7 +10,7 @@ @import "./components/page/style.scss"; @import "./components/page-pages/style.scss"; @import "./components/page-patterns/style.scss"; -@import "./components/page-templates-template-parts/style.scss"; +@import "./components/page-templates/style.scss"; @import "./components/table/style.scss"; @import "./components/sidebar-edit-mode/style.scss"; @import "./components/sidebar-edit-mode/page-panels/style.scss"; From 3e015b010dd9048994e5df250c833cc47cf45bb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:50:36 +0200 Subject: [PATCH 10/37] /wp_template_part/all: load patterns sidebar --- .../index.js | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index fc7e49d85aebf3..2419ee6058dd84 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -117,10 +117,18 @@ export default function SidebarNavigationScreenPatterns() { return ( } content={ <> @@ -129,11 +137,7 @@ export default function SidebarNavigationScreenPatterns() { <> { ! hasTemplateParts && ! hasPatterns && ( - - { __( - 'No template parts or patterns found' - ) } - + { __( 'No items found' ) } ) } Date: Fri, 12 Apr 2024 15:50:47 +0200 Subject: [PATCH 11/37] Remove template part loading logic --- .../index.js | 41 +++++-------------- 1 file changed, 10 insertions(+), 31 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js index 0f9d04332e7b6d..6ff18c206e899c 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js @@ -2,61 +2,40 @@ * WordPress dependencies */ import { __ } from '@wordpress/i18n'; -import { useSelect } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; /** * Internal dependencies */ import SidebarNavigationScreen from '../sidebar-navigation-screen'; -import { store as editSiteStore } from '../../store'; -import { TEMPLATE_POST_TYPE } from '../../utils/constants'; import { unlock } from '../../lock-unlock'; import DataviewsTemplatesSidebarContent from './content'; const config = { - [ TEMPLATE_POST_TYPE ]: { - title: __( 'Manage templates' ), - description: __( - 'Create new templates, or reset any customizations made to the templates supplied by your theme.' - ), - contentTitle: __( 'All templates' ), - }, - [ TEMPLATE_PART_POST_TYPE ]: { - title: __( 'Manage template parts' ), - description: __( - 'Create new template parts, or reset any customizations made to the template parts supplied by your theme.' - ), - backPath: { path: '/patterns' }, - contentTitle: __( 'All template parts' ), - }, + title: __( 'Manage templates' ), + description: __( + 'Create new templates, or reset any customizations made to the templates supplied by your theme.' + ), + contentTitle: __( 'All templates' ), }; const { useLocation } = unlock( routerPrivateApis ); export default function SidebarNavigationScreenTemplatesBrowse( { postType } ) { const { - params: { didAccessPatternsPage, activeView = 'all' }, + params: { activeView = 'all' }, } = useLocation(); - const isTemplatePartsMode = useSelect( ( select ) => { - return !! select( editSiteStore ).getSettings() - .supportsTemplatePartsMode; - }, [] ); - return ( } /> From 2be2331a411bd82a0771850d35a64c1580ee5b6b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 12 Apr 2024 15:57:25 +0200 Subject: [PATCH 12/37] Update e2e tests --- test/e2e/specs/site-editor/hybrid-theme.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/e2e/specs/site-editor/hybrid-theme.spec.js b/test/e2e/specs/site-editor/hybrid-theme.spec.js index 3cb9f0685abe5b..bbef68f72eed64 100644 --- a/test/e2e/specs/site-editor/hybrid-theme.spec.js +++ b/test/e2e/specs/site-editor/hybrid-theme.spec.js @@ -19,7 +19,7 @@ test.describe( 'Hybrid theme', () => { ); await expect( - page.getByRole( 'link', { name: 'header' } ) + page.getByText( 'header', { exact: true } ) ).toBeVisible(); } ); @@ -29,7 +29,7 @@ test.describe( 'Hybrid theme', () => { 'postType=wp_template_part&path=/wp_template_part/all' ); - const templatePart = page.getByRole( 'link', { name: 'header' } ); + const templatePart = page.getByText( 'header', { exact: true } ); await expect( templatePart ).toBeVisible(); await templatePart.click(); From 52cbb75409b1d430859c4e2188fc4c328ac3f74b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 10:04:39 +0200 Subject: [PATCH 13/37] Fix import after rebase --- packages/edit-site/src/components/layout/router.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index d46e65ff54b336..9561d3d3ac7ee5 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -13,7 +13,6 @@ import Editor from '../editor'; import PagePages from '../page-pages'; import PagePatterns from '../page-patterns'; import PageTemplates from '../page-templates'; -import PageTemplatesTemplateParts from '../page-templates-template-parts'; import SidebarNavigationScreen from '../sidebar-navigation-screen'; import SidebarNavigationScreenGlobalStyles from '../sidebar-navigation-screen-global-styles'; import SidebarNavigationScreenMain from '../sidebar-navigation-screen-main'; @@ -108,9 +107,7 @@ export default function useLayoutAreas() { sidebar: ( ), - content: ( - - ), + content: , preview: isListLayout && ( ), From 19ffef2da645e18c53107210b0d64e2014025cd3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:06:58 +0200 Subject: [PATCH 14/37] Fixup sidebar screen pattern --- .../src/components/sidebar-navigation-screen-pattern/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index 881413390987d4..c0161eb54d1fcc 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -30,7 +30,7 @@ export default function SidebarNavigationScreenPattern() { useInitEditedEntityFromURL(); const patternDetails = usePatternDetails( postType, postId ); - const backPath = '/patterns'; + const backPath = { path: '/patterns' }; return ( Date: Thu, 18 Apr 2024 13:25:02 +0200 Subject: [PATCH 15/37] Load the patterns screen for /wp_template_part/all --- .../edit-site/src/components/layout/router.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index 9561d3d3ac7ee5..bc07990adb3e64 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -119,6 +119,24 @@ export default function useLayoutAreas() { }; } + // Template parts + /* + * This is for legacy reasons, as the template parts are now part of the patterns screen. + * However, hybrid themes (classic themes that support template parts) still access this URL. + * While there are plans to make them use the patterns screen instead, we cannot do it for now. + * See discussion at https://github.com/WordPress/gutenberg/pull/60689 + */ + if ( path === '/wp_template_part/all' ) { + return { + key: 'template-parts', + areas: { + sidebar: , + content: , + mobile: , + }, + }; + } + // Patterns if ( path === '/patterns' ) { return { From b5cee39f62686676be1ca4c2fb03582a83c168de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:30:47 +0200 Subject: [PATCH 16/37] Use a generic copy that works for patterns & parts --- .../src/components/sidebar-navigation-screen-patterns/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 2419ee6058dd84..21ef0acca11e08 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -132,7 +132,7 @@ export default function SidebarNavigationScreenPatterns() { actions={ } content={ <> - { isLoading && __( 'Loading patterns…' ) } + { isLoading && __( 'Loading items…' ) } { ! isLoading && ( <> { ! hasTemplateParts && ! hasPatterns && ( From fcd10be6a60c519e8ed5a5700ab4fe4d551aabcd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:31:03 +0200 Subject: [PATCH 17/37] Do not load pattern categories for block themes --- .../components/sidebar-navigation-screen-patterns/index.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 21ef0acca11e08..cc42bf150d5f95 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -101,6 +101,7 @@ function CategoriesGroup( { ); } +const EMPTY_ARRAY = []; export default function SidebarNavigationScreenPatterns() { const { categoryType, categoryId } = getQueryArgs( window.location.href ); const currentCategory = categoryId || PATTERN_DEFAULT_CATEGORY; @@ -142,7 +143,11 @@ export default function SidebarNavigationScreenPatterns() { ) } From e487f2da5ebe8b4e51ad160d15164ccb4f6b6028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 13:44:16 +0200 Subject: [PATCH 18/37] Set category id & type properly when the path is /wp_template_part/all --- .../index.js | 21 ++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index cc42bf150d5f95..4fc2c8fa8e34a5 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -22,6 +22,7 @@ import { PATTERN_DEFAULT_CATEGORY, PATTERN_TYPES, TEMPLATE_PART_POST_TYPE, + TEMPLATE_PART_ALL_AREAS_CATEGORY, } from '../../utils/constants'; import usePatternCategories from './use-pattern-categories'; import useTemplatePartAreas from './use-template-part-areas'; @@ -43,10 +44,10 @@ function CategoriesGroup( { .reduce( ( acc, val ) => acc + val, 0 ) } icon={ getTemplatePartIcon() } /* no name, so it provides the fallback icon */ label={ __( 'All template parts' ) } - id={ 'all-parts' } + id={ TEMPLATE_PART_ALL_AREAS_CATEGORY } type={ TEMPLATE_PART_POST_TYPE } isActive={ - currentCategory === 'all-parts' && + currentCategory === TEMPLATE_PART_ALL_AREAS_CATEGORY && currentType === TEMPLATE_PART_POST_TYPE } /> @@ -103,9 +104,19 @@ function CategoriesGroup( { const EMPTY_ARRAY = []; export default function SidebarNavigationScreenPatterns() { - const { categoryType, categoryId } = getQueryArgs( window.location.href ); - const currentCategory = categoryId || PATTERN_DEFAULT_CATEGORY; - const currentType = categoryType || PATTERN_TYPES.theme; + const { categoryType, categoryId, path } = getQueryArgs( + window.location.href + ); + const currentCategory = + categoryId || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_ALL_AREAS_CATEGORY + : PATTERN_DEFAULT_CATEGORY ); + const currentType = + categoryType || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_POST_TYPE + : PATTERN_TYPES.theme ); const { templatePartAreas, hasTemplateParts, isLoading } = useTemplatePartAreas(); From 21af7ea5542718c67eb6c76104240ae30f518f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:00:45 +0200 Subject: [PATCH 19/37] Content frame: set category id & type properly when the path is /wp_template_part/all --- .../src/components/page-patterns/index.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/index.js b/packages/edit-site/src/components/page-patterns/index.js index 063632c493822b..76cfce98627fc1 100644 --- a/packages/edit-site/src/components/page-patterns/index.js +++ b/packages/edit-site/src/components/page-patterns/index.js @@ -50,6 +50,7 @@ import { LAYOUT_LIST, PATTERN_TYPES, TEMPLATE_PART_POST_TYPE, + TEMPLATE_PART_ALL_AREAS_CATEGORY, PATTERN_SYNC_TYPES, PATTERN_DEFAULT_CATEGORY, ENUMERATION_TYPE, @@ -310,9 +311,21 @@ function Title( { item, categoryId } ) { } export default function DataviewsPatterns() { - const { categoryType, categoryId = PATTERN_DEFAULT_CATEGORY } = - getQueryArgs( window.location.href ); - const type = categoryType || PATTERN_TYPES.theme; + const { + categoryType, + categoryId: categoryIdFromURL, + path, + } = getQueryArgs( window.location.href ); + const type = + categoryType || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_POST_TYPE + : PATTERN_TYPES.theme ); + const categoryId = + categoryIdFromURL || + ( path === '/wp_template_part/all' + ? TEMPLATE_PART_ALL_AREAS_CATEGORY + : PATTERN_DEFAULT_CATEGORY ); const [ view, setView ] = useState( DEFAULT_VIEW ); const isUncategorizedThemePatterns = type === PATTERN_TYPES.theme && categoryId === 'uncategorized'; From 8bb97433565f7b43611247c82bee9debab778554 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 14:12:14 +0200 Subject: [PATCH 20/37] Go back to /wp_template_part/all for non-block based themes --- .../sidebar-navigation-screen-pattern/index.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index c0161eb54d1fcc..e4673d75b71d4b 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -1,10 +1,11 @@ /** * WordPress dependencies */ -import { useDispatch } from '@wordpress/data'; +import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { pencil } from '@wordpress/icons'; import { privateApis as routerPrivateApis } from '@wordpress/router'; +import { store as coreStore } from '@wordpress/core-data'; /** * Internal dependencies @@ -30,7 +31,13 @@ export default function SidebarNavigationScreenPattern() { useInitEditedEntityFromURL(); const patternDetails = usePatternDetails( postType, postId ); - const backPath = { path: '/patterns' }; + const isBlockBasedTheme = useSelect( + ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme, + [] + ); + const backPath = isBlockBasedTheme + ? { path: '/patterns' } + : { path: '/wp_template_part/all' }; return ( Date: Thu, 18 Apr 2024 14:17:52 +0200 Subject: [PATCH 21/37] Use the existing page path (either /patterns or /wp_template_part/all --- .../sidebar-navigation-screen-patterns/category-item.js | 3 ++- .../components/sidebar-navigation-screen-patterns/index.js | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js index 894cd5f8048183..49274a0435bafa 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/category-item.js @@ -11,9 +11,10 @@ export default function CategoryItem( { isActive, label, type, + path = '/patterns', } ) { const linkInfo = useLink( { - path: '/patterns', + path, categoryType: type, categoryId: id, } ); diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 4fc2c8fa8e34a5..c7d125cb573806 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -28,6 +28,7 @@ import usePatternCategories from './use-pattern-categories'; import useTemplatePartAreas from './use-template-part-areas'; function CategoriesGroup( { + path, templatePartAreas, patternCategories, currentCategory, @@ -39,6 +40,7 @@ function CategoriesGroup( { templateParts?.length || 0 ) .reduce( ( acc, val ) => acc + val, 0 ) } @@ -55,6 +57,7 @@ function CategoriesGroup( { ( [ area, { label, templateParts } ] ) => ( ( ) } Date: Thu, 18 Apr 2024 17:04:39 +0200 Subject: [PATCH 22/37] Revert changes to get-is-list-page --- packages/edit-site/src/utils/get-is-list-page.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/utils/get-is-list-page.js b/packages/edit-site/src/utils/get-is-list-page.js index f7312ec3c1c292..0fa818c28cb510 100644 --- a/packages/edit-site/src/utils/get-is-list-page.js +++ b/packages/edit-site/src/utils/get-is-list-page.js @@ -14,7 +14,9 @@ export default function getIsListPage( isMobileViewport ) { return ( - [ '/wp_template', '/pages' ].includes( path ) || + [ '/wp_template', '/wp_template_part/all', '/pages' ].includes( + path + ) || ( path === '/patterns' && // Don't treat "/patterns" without categoryType and categoryId as a // list page in mobile because the sidebar covers the whole page. From 4afe1597981129666ab542a7adf18693ac0e0e70 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:05:09 +0200 Subject: [PATCH 23/37] Revert changes to sync entity --- .../sync-state-with-url/use-init-edited-entity-from-url.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js index 1f9d71945f76cf..8cfb0bca716f2f 100644 --- a/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js +++ b/packages/edit-site/src/components/sync-state-with-url/use-init-edited-entity-from-url.js @@ -226,6 +226,10 @@ function useResolveEditedEntityAndContext( { path, postId, postType } ) { return { isReady: true, postType: 'wp_template', postId, context }; } + if ( path === '/wp_template_part/all' && postId ) { + return { isReady: true, postType: 'wp_template_part', postId, context }; + } + if ( postTypesWithoutParentTemplate.includes( postType ) ) { return { isReady: true, postType, postId, context }; } From 195b50d2278b4bf7c31df2b5af39fc0dd3128111 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Thu, 18 Apr 2024 17:48:32 +0200 Subject: [PATCH 24/37] Template sidebar: remove postType configuration --- packages/edit-site/src/components/layout/router.js | 4 +--- .../sidebar-navigation-screen-templates-browse/content.js | 4 ++-- .../sidebar-navigation-screen-templates-browse/index.js | 3 +-- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/packages/edit-site/src/components/layout/router.js b/packages/edit-site/src/components/layout/router.js index bc07990adb3e64..bce9043a77e1b0 100644 --- a/packages/edit-site/src/components/layout/router.js +++ b/packages/edit-site/src/components/layout/router.js @@ -104,9 +104,7 @@ export default function useLayoutAreas() { return { key: 'templates-list', areas: { - sidebar: ( - - ), + sidebar: , content: , preview: isListLayout && ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js index 7e69f4c60c5a8d..e7f11f07e82a20 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/content.js @@ -11,6 +11,7 @@ import { __experimentalItemGroup as ItemGroup } from '@wordpress/components'; import DataViewItem from '../sidebar-dataviews/dataview-item'; import { useAddedBy } from '../page-templates/hooks'; import { layout } from '@wordpress/icons'; +import { TEMPLATE_POST_TYPE } from '../../utils/constants'; const EMPTY_ARRAY = []; @@ -30,10 +31,9 @@ function TemplateDataviewItem( { template, isActive } ) { export default function DataviewsTemplatesSidebarContent( { activeView, - postType, title, } ) { - const { records } = useEntityRecords( 'postType', postType, { + const { records } = useEntityRecords( 'postType', TEMPLATE_POST_TYPE, { per_page: -1, } ); const firstItemPerAuthorText = useMemo( () => { diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js index 6ff18c206e899c..46a828dba59c8e 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js @@ -21,7 +21,7 @@ const config = { const { useLocation } = unlock( routerPrivateApis ); -export default function SidebarNavigationScreenTemplatesBrowse( { postType } ) { +export default function SidebarNavigationScreenTemplatesBrowse() { const { params: { activeView = 'all' }, } = useLocation(); @@ -34,7 +34,6 @@ export default function SidebarNavigationScreenTemplatesBrowse( { postType } ) { content={ } From 2ea07e2491ac2b6bc89e60009d87fc26ed53dd68 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Fri, 19 Apr 2024 10:26:48 +0200 Subject: [PATCH 25/37] Hide actions for themes that are not block based --- .../src/components/add-new-pattern/index.js | 18 ++++++------------ .../index.js | 2 +- 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/packages/edit-site/src/components/add-new-pattern/index.js b/packages/edit-site/src/components/add-new-pattern/index.js index 0d25ff67bf4482..f306da4eb27a66 100644 --- a/packages/edit-site/src/components/add-new-pattern/index.js +++ b/packages/edit-site/src/components/add-new-pattern/index.js @@ -5,13 +5,12 @@ import { DropdownMenu } from '@wordpress/components'; import { useState, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { plus, symbol, symbolFilled, upload } from '@wordpress/icons'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { useDispatch } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { privateApis as editPatternsPrivateApis, store as patternsStore, } from '@wordpress/patterns'; -import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; /** @@ -37,9 +36,6 @@ export default function AddNewPattern() { const [ showPatternModal, setShowPatternModal ] = useState( false ); const [ showTemplatePartModal, setShowTemplatePartModal ] = useState( false ); - const isBlockBasedTheme = useSelect( ( select ) => { - return select( coreStore ).getCurrentTheme()?.is_block_theme; - }, [] ); const { createPatternFromFile } = unlock( useDispatch( patternsStore ) ); const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); @@ -81,13 +77,11 @@ export default function AddNewPattern() { }, ]; - if ( isBlockBasedTheme ) { - controls.push( { - icon: symbolFilled, - onClick: () => setShowTemplatePartModal( true ), - title: __( 'Create template part' ), - } ); - } + controls.push( { + icon: symbolFilled, + onClick: () => setShowTemplatePartModal( true ), + title: __( 'Create template part' ), + } ); controls.push( { icon: upload, diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index c7d125cb573806..008f1a8a2b7af7 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -146,7 +146,7 @@ export default function SidebarNavigationScreenPatterns() { 'Manage what template parts are available when editing the site.' ) } - actions={ } + actions={ isBlockBasedTheme && } content={ <> { isLoading && __( 'Loading items…' ) } From cc9d537d321a19a0862ce25bc9333317f149a4e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:38:13 +0200 Subject: [PATCH 26/37] List patterns as well --- .../index.js | 40 +++++++++++++------ 1 file changed, 28 insertions(+), 12 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 008f1a8a2b7af7..221765e981f416 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -112,16 +112,15 @@ export default function SidebarNavigationScreenPatterns() { const { categoryType, categoryId, path } = getQueryArgs( window.location.href ); + const isTemplatePartsPath = path === '/wp_template_part/all'; const currentCategory = categoryId || - ( path === '/wp_template_part/all' + ( isTemplatePartsPath ? TEMPLATE_PART_ALL_AREAS_CATEGORY : PATTERN_DEFAULT_CATEGORY ); const currentType = categoryType || - ( path === '/wp_template_part/all' - ? TEMPLATE_PART_POST_TYPE - : PATTERN_TYPES.theme ); + ( isTemplatePartsPath ? TEMPLATE_PART_POST_TYPE : PATTERN_TYPES.theme ); const { templatePartAreas, hasTemplateParts, isLoading } = useTemplatePartAreas(); @@ -131,19 +130,32 @@ export default function SidebarNavigationScreenPatterns() { [] ); + /** + * This sidebar needs to temporarily accomodate 3 different "screens": + * + * 1. Block based themes: list Patterns + Template Parts. + * + * 2. Classic themes: list Patterns. + * The URL is accessible though not linked anywhere. + * + * 3. Hybrid themes (classic themes with support for block-template-parts): list Template Parts. + * The URL is accessible from the Appearance > Template Parts menu. + * + * This is temporary. We aim to list Patterns & Template Parts in all 3 scenarios. + */ return ( } @@ -159,12 +171,16 @@ export default function SidebarNavigationScreenPatterns() { ) } From 4143618e9fe21d733d79697ee70962dc50a9694a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 11:47:07 +0200 Subject: [PATCH 27/37] Fix backpath for non block based themes --- .../components/sidebar-navigation-screen-pattern/index.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index e4673d75b71d4b..c79acd6f55371d 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -35,9 +35,10 @@ export default function SidebarNavigationScreenPattern() { ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme, [] ); - const backPath = isBlockBasedTheme - ? { path: '/patterns' } - : { path: '/wp_template_part/all' }; + const backPath = + ! isBlockBasedTheme && postType === 'wp_template_part' + ? { path: '/wp_template_part/all' } + : { path: '/patterns' }; return ( Date: Mon, 22 Apr 2024 12:06:48 +0200 Subject: [PATCH 28/37] Update Patterns sidebar --- .../index.js | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 221765e981f416..d6f22b75739dbd 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -131,17 +131,16 @@ export default function SidebarNavigationScreenPatterns() { ); /** - * This sidebar needs to temporarily accomodate 3 different "screens": + * This sidebar needs to temporarily accomodate two different "URLs": * - * 1. Block based themes: list Patterns + Template Parts. + * 1. path = /patterns + * Block based themes. Also classic themes can access this URL, though it's not linked anywhere. * - * 2. Classic themes: list Patterns. - * The URL is accessible though not linked anywhere. - * - * 3. Hybrid themes (classic themes with support for block-template-parts): list Template Parts. + * 2. path = /wp_template_part/all + * Classic themes with support for block-template-parts). We need to list only] Template Parts in this case. * The URL is accessible from the Appearance > Template Parts menu. * - * This is temporary. We aim to list Patterns & Template Parts in all 3 scenarios. + * This is temporary. We aim to consolidate to /patterns. */ return ( } + actions={ isTemplatePartsPath && } content={ <> { isLoading && __( 'Loading items…' ) } @@ -171,11 +170,7 @@ export default function SidebarNavigationScreenPatterns() { ) } Date: Mon, 22 Apr 2024 12:11:44 +0200 Subject: [PATCH 29/37] Fix backpath for Pattern sidebar --- .../sidebar-navigation-screen-pattern/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index c79acd6f55371d..dd41fe9e19d398 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -5,7 +5,6 @@ import { useDispatch, useSelect } from '@wordpress/data'; import { __ } from '@wordpress/i18n'; import { pencil } from '@wordpress/icons'; import { privateApis as routerPrivateApis } from '@wordpress/router'; -import { store as coreStore } from '@wordpress/core-data'; /** * Internal dependencies @@ -31,12 +30,13 @@ export default function SidebarNavigationScreenPattern() { useInitEditedEntityFromURL(); const patternDetails = usePatternDetails( postType, postId ); - const isBlockBasedTheme = useSelect( - ( select ) => select( coreStore ).getCurrentTheme()?.is_block_theme, - [] - ); + const isTemplatePartsMode = useSelect( ( select ) => { + return !! select( editSiteStore ).getSettings() + .supportsTemplatePartsMode; + }, [] ); + const backPath = - ! isBlockBasedTheme && postType === 'wp_template_part' + isTemplatePartsMode && postType === 'wp_template_part' ? { path: '/wp_template_part/all' } : { path: '/patterns' }; From c635c42bb4915982ac726e553c8eadb243ea4c8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:51:13 +0200 Subject: [PATCH 30/37] Show actions when the path is not /wp_template_part/all --- .../src/components/sidebar-navigation-screen-patterns/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index d6f22b75739dbd..57a8e8420e5954 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -157,7 +157,7 @@ export default function SidebarNavigationScreenPatterns() { 'Manage what patterns are available when editing the site.' ) } - actions={ isTemplatePartsPath && } + actions={ ! isTemplatePartsPath && } content={ <> { isLoading && __( 'Loading items…' ) } From 45ee635d8297103c745fa2e71d5be802545db371 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 12:59:47 +0200 Subject: [PATCH 31/37] Non block based themes cannot create template parts --- .../src/components/add-new-pattern/index.js | 18 ++++++++++++------ .../index.js | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/packages/edit-site/src/components/add-new-pattern/index.js b/packages/edit-site/src/components/add-new-pattern/index.js index f306da4eb27a66..0d25ff67bf4482 100644 --- a/packages/edit-site/src/components/add-new-pattern/index.js +++ b/packages/edit-site/src/components/add-new-pattern/index.js @@ -5,12 +5,13 @@ import { DropdownMenu } from '@wordpress/components'; import { useState, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { plus, symbol, symbolFilled, upload } from '@wordpress/icons'; -import { useDispatch } from '@wordpress/data'; +import { useSelect, useDispatch } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { privateApis as editPatternsPrivateApis, store as patternsStore, } from '@wordpress/patterns'; +import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; /** @@ -36,6 +37,9 @@ export default function AddNewPattern() { const [ showPatternModal, setShowPatternModal ] = useState( false ); const [ showTemplatePartModal, setShowTemplatePartModal ] = useState( false ); + const isBlockBasedTheme = useSelect( ( select ) => { + return select( coreStore ).getCurrentTheme()?.is_block_theme; + }, [] ); const { createPatternFromFile } = unlock( useDispatch( patternsStore ) ); const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); @@ -77,11 +81,13 @@ export default function AddNewPattern() { }, ]; - controls.push( { - icon: symbolFilled, - onClick: () => setShowTemplatePartModal( true ), - title: __( 'Create template part' ), - } ); + if ( isBlockBasedTheme ) { + controls.push( { + icon: symbolFilled, + onClick: () => setShowTemplatePartModal( true ), + title: __( 'Create template part' ), + } ); + } controls.push( { icon: upload, diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 57a8e8420e5954..5d2cf5850f1f94 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -157,7 +157,7 @@ export default function SidebarNavigationScreenPatterns() { 'Manage what patterns are available when editing the site.' ) } - actions={ ! isTemplatePartsPath && } + actions={ } content={ <> { isLoading && __( 'Loading items…' ) } From 627ded8ee820ccf6816518768c027ff55bb523c3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 13:06:04 +0200 Subject: [PATCH 32/37] Update copy for /wp_template_part/all screen --- packages/edit-site/src/components/page-patterns/header.js | 6 ++---- .../components/sidebar-navigation-screen-patterns/index.js | 6 ++++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/header.js b/packages/edit-site/src/components/page-patterns/header.js index 7cca997c7dd02e..0bae092ea66ce5 100644 --- a/packages/edit-site/src/components/page-patterns/header.js +++ b/packages/edit-site/src/components/page-patterns/header.js @@ -40,10 +40,8 @@ export default function PatternsHeader( { const templatePartArea = templatePartAreas.find( ( area ) => area.area === categoryId ); - title = templatePartArea?.label || __( 'All Template Parts' ); - description = - templatePartArea?.description || - __( 'Includes every template part defined for any area.' ); + title = templatePartArea?.label || __( 'Template Parts' ); + description = templatePartArea?.description; } else if ( type === PATTERN_TYPES.theme ) { patternCategory = patternCategories.find( ( category ) => category.name === categoryId diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 5d2cf5850f1f94..ec8cd00556ea6c 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -146,12 +146,14 @@ export default function SidebarNavigationScreenPatterns() { Date: Mon, 22 Apr 2024 13:12:50 +0200 Subject: [PATCH 33/37] Improve logic to show actions --- .../src/components/add-new-pattern/index.js | 36 +++++++++---------- .../index.js | 7 +++- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/packages/edit-site/src/components/add-new-pattern/index.js b/packages/edit-site/src/components/add-new-pattern/index.js index 0d25ff67bf4482..8c051d5ca51ec3 100644 --- a/packages/edit-site/src/components/add-new-pattern/index.js +++ b/packages/edit-site/src/components/add-new-pattern/index.js @@ -5,13 +5,12 @@ import { DropdownMenu } from '@wordpress/components'; import { useState, useRef } from '@wordpress/element'; import { __, sprintf } from '@wordpress/i18n'; import { plus, symbol, symbolFilled, upload } from '@wordpress/icons'; -import { useSelect, useDispatch } from '@wordpress/data'; +import { useDispatch } from '@wordpress/data'; import { privateApis as routerPrivateApis } from '@wordpress/router'; import { privateApis as editPatternsPrivateApis, store as patternsStore, } from '@wordpress/patterns'; -import { store as coreStore } from '@wordpress/core-data'; import { store as noticesStore } from '@wordpress/notices'; /** @@ -31,15 +30,12 @@ const { CreatePatternModal, useAddPatternCategory } = unlock( editPatternsPrivateApis ); -export default function AddNewPattern() { +export default function AddNewPattern( { canCreateParts, canCreatePatterns } ) { const history = useHistory(); const { params } = useLocation(); const [ showPatternModal, setShowPatternModal ] = useState( false ); const [ showTemplatePartModal, setShowTemplatePartModal ] = useState( false ); - const isBlockBasedTheme = useSelect( ( select ) => { - return select( coreStore ).getCurrentTheme()?.is_block_theme; - }, [] ); const { createPatternFromFile } = unlock( useDispatch( patternsStore ) ); const { createSuccessNotice, createErrorNotice } = useDispatch( noticesStore ); @@ -73,15 +69,17 @@ export default function AddNewPattern() { setShowTemplatePartModal( false ); } - const controls = [ - { + const controls = []; + + if ( canCreatePatterns ) { + controls.push( { icon: symbol, onClick: () => setShowPatternModal( true ), title: __( 'Create pattern' ), - }, - ]; + } ); + } - if ( isBlockBasedTheme ) { + if ( canCreateParts ) { controls.push( { icon: symbolFilled, onClick: () => setShowTemplatePartModal( true ), @@ -89,13 +87,15 @@ export default function AddNewPattern() { } ); } - controls.push( { - icon: upload, - onClick: () => { - patternUploadInputRef.current.click(); - }, - title: __( 'Import pattern from JSON' ), - } ); + if ( canCreatePatterns ) { + controls.push( { + icon: upload, + onClick: () => { + patternUploadInputRef.current.click(); + }, + title: __( 'Import pattern from JSON' ), + } ); + } const { categoryMap, findOrCreateTerm } = useAddPatternCategory(); return ( diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index ec8cd00556ea6c..59532ccc7fbbac 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -159,7 +159,12 @@ export default function SidebarNavigationScreenPatterns() { 'Manage what patterns are available when editing the site.' ) } - actions={ } + actions={ + + } content={ <> { isLoading && __( 'Loading items…' ) } From 5192d86d60a1ec1f130637b5b21d87dcbd0f4c7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:35:18 +0200 Subject: [PATCH 34/37] Inline strings --- .../index.js | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js index 46a828dba59c8e..d48314d1f36e64 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-templates-browse/index.js @@ -11,14 +11,6 @@ import SidebarNavigationScreen from '../sidebar-navigation-screen'; import { unlock } from '../../lock-unlock'; import DataviewsTemplatesSidebarContent from './content'; -const config = { - title: __( 'Manage templates' ), - description: __( - 'Create new templates, or reset any customizations made to the templates supplied by your theme.' - ), - contentTitle: __( 'All templates' ), -}; - const { useLocation } = unlock( routerPrivateApis ); export default function SidebarNavigationScreenTemplatesBrowse() { @@ -28,13 +20,14 @@ export default function SidebarNavigationScreenTemplatesBrowse() { return ( } /> From 2dbe1c5d15ad27deba110c825a3c1852321c440b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 14:41:09 +0200 Subject: [PATCH 35/37] Document backpath --- .../sidebar-navigation-screen-pattern/index.js | 13 +++++++++++++ .../sidebar-navigation-screen-patterns/index.js | 2 +- 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js index dd41fe9e19d398..8b459e3ea6a91a 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-pattern/index.js @@ -35,6 +35,19 @@ export default function SidebarNavigationScreenPattern() { .supportsTemplatePartsMode; }, [] ); + /** + * This sidebar needs to temporarily accomodate two different "URLs" backpaths: + * + * 1. path = /patterns + * Block based themes. Also classic themes can access this URL, though it's not linked anywhere. + * + * 2. path = /wp_template_part/all + * Classic themes with support for block-template-parts. We need to list only Template Parts in this case. + * The URL is accessible from the Appearance > Template Parts menu. + * + * Depending on whether the theme supports block-template-parts, we go back to Patterns or Template screens. + * This is temporary. We aim to consolidate to /patterns. + */ const backPath = isTemplatePartsMode && postType === 'wp_template_part' ? { path: '/wp_template_part/all' } diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 59532ccc7fbbac..332e20c98d8b44 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -137,7 +137,7 @@ export default function SidebarNavigationScreenPatterns() { * Block based themes. Also classic themes can access this URL, though it's not linked anywhere. * * 2. path = /wp_template_part/all - * Classic themes with support for block-template-parts). We need to list only] Template Parts in this case. + * Classic themes with support for block-template-parts. We need to list only Template Parts in this case. * The URL is accessible from the Appearance > Template Parts menu. * * This is temporary. We aim to consolidate to /patterns. From 08e8ebeb81985a8512f6861c858516adda5ba04b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 17:49:18 +0200 Subject: [PATCH 36/37] Do not render button if no actions --- .../sidebar-navigation-screen-patterns/index.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js index 332e20c98d8b44..d795bfb9a893a5 100644 --- a/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js +++ b/packages/edit-site/src/components/sidebar-navigation-screen-patterns/index.js @@ -160,10 +160,12 @@ export default function SidebarNavigationScreenPatterns() { ) } actions={ - + ( isBlockBasedTheme || ! isTemplatePartsPath ) && ( + + ) } content={ <> From 18c6a0bb015f98bf9c7ee956eb7274b679e4c9b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Maneiro?= <583546+oandregal@users.noreply.github.com> Date: Mon, 22 Apr 2024 17:50:34 +0200 Subject: [PATCH 37/37] Revert back changes to content title copy --- packages/edit-site/src/components/page-patterns/header.js | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/page-patterns/header.js b/packages/edit-site/src/components/page-patterns/header.js index 0bae092ea66ce5..7cca997c7dd02e 100644 --- a/packages/edit-site/src/components/page-patterns/header.js +++ b/packages/edit-site/src/components/page-patterns/header.js @@ -40,8 +40,10 @@ export default function PatternsHeader( { const templatePartArea = templatePartAreas.find( ( area ) => area.area === categoryId ); - title = templatePartArea?.label || __( 'Template Parts' ); - description = templatePartArea?.description; + title = templatePartArea?.label || __( 'All Template Parts' ); + description = + templatePartArea?.description || + __( 'Includes every template part defined for any area.' ); } else if ( type === PATTERN_TYPES.theme ) { patternCategory = patternCategories.find( ( category ) => category.name === categoryId