Skip to content

Commit

Permalink
Remove general templates from pages
Browse files Browse the repository at this point in the history
  • Loading branch information
david-szabo97 committed Jan 18, 2021
1 parent 51954f9 commit 6abcd28
Showing 1 changed file with 9 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,8 @@ import { map } from 'lodash';
/**
* WordPress dependencies
*/
import {
__experimentalNavigationGroup as NavigationGroup,
__experimentalNavigationMenu as NavigationMenu,
} from '@wordpress/components';
import { __, _x } from '@wordpress/i18n';
import { __experimentalNavigationMenu as NavigationMenu } from '@wordpress/components';
import { __ } from '@wordpress/i18n';

/**
* Internal dependencies
Expand All @@ -19,7 +16,6 @@ import TemplateNavigationItem from '../template-navigation-item';
import { MENU_TEMPLATES, MENU_TEMPLATES_PAGES } from '../constants';

export default function TemplatesPagesMenu( { templates } ) {
const defaultTemplate = templates?.find( ( { slug } ) => slug === 'page' );
const specificTemplates =
templates?.filter( ( { slug } ) => slug.startsWith( 'page-' ) ) ?? [];

Expand All @@ -28,22 +24,14 @@ export default function TemplatesPagesMenu( { templates } ) {
menu={ MENU_TEMPLATES_PAGES }
title={ __( 'Pages' ) }
parentMenu={ MENU_TEMPLATES }
isEmpty={ ! defaultTemplate && specificTemplates.length === 0 }
isEmpty={ specificTemplates.length === 0 }
>
<NavigationGroup title={ _x( 'Specific', 'specific templates' ) }>
{ map( specificTemplates, ( template ) => (
<TemplateNavigationItem
item={ template }
key={ `wp_template-${ template.id }` }
/>
) ) }
</NavigationGroup>

{ defaultTemplate && (
<NavigationGroup title={ _x( 'General', 'general templates' ) }>
<TemplateNavigationItem item={ defaultTemplate } />
</NavigationGroup>
) }
{ map( specificTemplates, ( template ) => (
<TemplateNavigationItem
item={ template }
key={ `wp_template-${ template.id }` }
/>
) ) }
</NavigationMenu>
);
}

0 comments on commit 6abcd28

Please sign in to comment.