From 7305ed33dc6909d05b31145314204ad500b930b2 Mon Sep 17 00:00:00 2001 From: Matt Wiebe Date: Tue, 3 Nov 2020 08:52:43 -0600 Subject: [PATCH] Site Editor: reorder template creation dropdown (#26610) The items were previously in alphabetical order by slug, as with any keyed JS object. This allowed '404' to be first, which is not a very important template. --- .../navigation-panel/new-template-dropdown.js | 10 +-- .../src/utils/get-template-info/constants.js | 65 ++++++++++--------- .../src/utils/get-template-info/index.js | 7 +- 3 files changed, 48 insertions(+), 34 deletions(-) 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 8ecfce1a18b75e..1248d2948d9d63 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 @@ -1,7 +1,7 @@ /** * External dependencies */ -import { map, omit } from 'lodash'; +import { map, filter, includes } from 'lodash'; /** * WordPress dependencies @@ -46,9 +46,11 @@ export default function NewTemplateDropdown() { } ); }; - const missingTemplates = omit( + const existingTemplateSlugs = map( templates, 'slug' ); + + const missingTemplates = filter( TEMPLATES_DEFAULT_DETAILS, - map( templates, 'slug' ) + ( template ) => ! includes( existingTemplateSlugs, template.slug ) ); return ( @@ -70,7 +72,7 @@ export default function NewTemplateDropdown() { { map( missingTemplates, - ( { title, description }, slug ) => ( + ( { title, description, slug } ) => (