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: Update the new templates dropdown list #27235

Merged
merged 2 commits into from
Nov 24, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 ) => {
Expand Down Expand Up @@ -59,9 +59,15 @@ export default function NewTemplateDropdown() {

const missingTemplates = filter(
defaultTemplateTypes,
( template ) => ! includes( existingTemplateSlugs, template.slug )
( template ) =>
includes( TEMPLATES_NEW_OPTIONS, template.slug ) &&
! includes( existingTemplateSlugs, template.slug )
);

if ( ! missingTemplates.length ) {
return null;
}

return (
<DropdownMenu
className="edit-site-navigation-panel__new-template-dropdown"
Expand Down