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

Navigation: Try removing "Add all pages" from placeholder. #36775

Merged
merged 3 commits into from Jan 28, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
19 changes: 0 additions & 19 deletions packages/block-library/src/navigation/edit/placeholder/index.js
@@ -1,7 +1,6 @@
/**
* WordPress dependencies
*/
import { createBlock } from '@wordpress/blocks';
import {
Placeholder,
Button,
Expand Down Expand Up @@ -124,7 +123,6 @@ export default function NavigationPlaceholder( {
isResolvingPages,
menus,
isResolvingMenus,
hasPages,
hasMenus,
} = useNavigationEntities();

Expand All @@ -134,11 +132,6 @@ export default function NavigationPlaceholder( {
onFinishMenuCreation( [] );
};

const onCreateAllPages = () => {
const block = [ createBlock( 'core/page-list' ) ];
onFinishMenuCreation( block );
};

const { navigationMenus } = useNavigationMenu();

const hasNavigationMenus = !! navigationMenus?.length;
Expand Down Expand Up @@ -181,18 +174,6 @@ export default function NavigationPlaceholder( {
<hr />
</>
) : undefined }
{ canUserCreateNavigation && hasPages ? (
<>
<Button
variant="tertiary"
onClick={ onCreateAllPages }
>
{ __( 'Add all pages' ) }
</Button>
<hr />
</>
) : undefined }

{ canUserCreateNavigation && (
<Button
variant="tertiary"
Expand Down
Expand Up @@ -42,8 +42,6 @@ exports[`Navigation placeholder allows a navigation block to be created from exi
<!-- /wp:navigation-submenu -->"
`;

exports[`Navigation placeholder allows a navigation block to be created using existing pages 1`] = `"<!-- wp:page-list /-->"`;

exports[`Navigation placeholder creates an empty navigation block when the selected existing menu is also empty 1`] = `""`;

exports[`Navigation supports navigation blocks that have inner blocks within their markup and converts them to wp_navigation posts 1`] = `"<!-- wp:page-list /-->"`;
50 changes: 0 additions & 50 deletions packages/e2e-tests/specs/editor/blocks/navigation.test.js
Expand Up @@ -124,7 +124,6 @@ async function selectClassicMenu( optionText ) {
const PLACEHOLDER_ACTIONS_CLASS = 'wp-block-navigation-placeholder__actions';
const PLACEHOLDER_ACTIONS_XPATH = `//*[contains(@class, '${ PLACEHOLDER_ACTIONS_CLASS }')]`;
const START_EMPTY_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Start empty']`;
const ADD_ALL_PAGES_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Add all pages']`;
const SELECT_MENU_XPATH = `${ PLACEHOLDER_ACTIONS_XPATH }//button[text()='Select menu']`;

/**
Expand Down Expand Up @@ -154,24 +153,6 @@ async function deleteAll( endpoints ) {
}
}

/**
* Create a set of pages using the REST API.
*
* @param {Array} pages An array of page objects.
*/
async function createPages( pages ) {
for ( const page of pages ) {
await rest( {
method: 'POST',
path: PAGES_ENDPOINT,
data: {
status: 'publish',
...page,
},
} );
}
}

/**
* Replace unique ids in nav block content, since these won't be consistent
* between test runs.
Expand Down Expand Up @@ -257,37 +238,6 @@ describe( 'Navigation', () => {
} );

describe( 'placeholder', () => {
it( 'allows a navigation block to be created using existing pages', async () => {
await createPages( [
{
title: 'About',
menu_order: 0,
},
{
title: 'Contact Us',
menu_order: 1,
},
{
title: 'FAQ',
menu_order: 2,
},
] );

await createNewPost();

// Add the navigation block.
await insertBlock( 'Navigation' );
const allPagesButton = await page.waitForXPath(
ADD_ALL_PAGES_XPATH
);
await allPagesButton.click();

// Wait for the page list block to be present
await page.waitForSelector( 'ul[aria-label="Block: Page List"]' );

expect( await getNavigationMenuRawContent() ).toMatchSnapshot();
} );

it( 'allows a navigation block to be created from existing menus', async () => {
await createClassicMenu( { name: 'Test Menu 1' } );
await createClassicMenu(
Expand Down