From 641932bfc61c699179954ef3f9ce8e29d04610cd Mon Sep 17 00:00:00 2001 From: Copons Date: Tue, 24 Nov 2020 12:53:23 +0000 Subject: [PATCH 1/2] Hand-pick the new templates dropdown list --- .../navigation-sidebar/navigation-panel/constants.js | 10 ++++++++++ .../navigation-panel/new-template-dropdown.js | 6 ++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/constants.js b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/constants.js index 5738942e4779d..e0201af342097 100644 --- a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/constants.js +++ b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/constants.js @@ -11,6 +11,16 @@ export const TEMPLATES_POSTS = [ 'home', 'single' ]; export const TEMPLATES_STATUSES = [ 'publish', 'draft', 'auto-draft' ]; +export const TEMPLATES_NEW_OPTIONS = [ + 'front-page', + 'single-post', + 'page', + 'archive', + 'search', + '404', + 'index', +]; + export const MENU_ROOT = 'root'; export const MENU_CONTENT_CATEGORIES = 'content-categories'; export const MENU_CONTENT_PAGES = 'content-pages'; diff --git a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js index c20afcf5f0e8c..9981e970ca7ad 100644 --- a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +++ b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js @@ -20,7 +20,7 @@ import { Icon, plus } from '@wordpress/icons'; * Internal dependencies */ import getClosestAvailableTemplate from '../../../utils/get-closest-available-template'; -import { TEMPLATES_STATUSES } from './constants'; +import { TEMPLATES_NEW_OPTIONS, TEMPLATES_STATUSES } from './constants'; export default function NewTemplateDropdown() { const { defaultTemplateTypes, templates } = useSelect( ( select ) => { @@ -59,7 +59,9 @@ export default function NewTemplateDropdown() { const missingTemplates = filter( defaultTemplateTypes, - ( template ) => ! includes( existingTemplateSlugs, template.slug ) + ( template ) => + includes( TEMPLATES_NEW_OPTIONS, template.slug ) && + ! includes( existingTemplateSlugs, template.slug ) ); return ( From 3b6ba7398d39ea7397707dc49211286ac0f5aacd Mon Sep 17 00:00:00 2001 From: Copons Date: Tue, 24 Nov 2020 13:59:35 +0000 Subject: [PATCH 2/2] Hide new template button when no templates are available --- .../navigation-panel/new-template-dropdown.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js index 9981e970ca7ad..c428472a051f2 100644 --- a/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js +++ b/packages/edit-site/src/components/navigation-sidebar/navigation-panel/new-template-dropdown.js @@ -64,6 +64,10 @@ export default function NewTemplateDropdown() { ! includes( existingTemplateSlugs, template.slug ) ); + if ( ! missingTemplates.length ) { + return null; + } + return (