From d8121e69881e65b91d60da0fd260c3e94da830e4 Mon Sep 17 00:00:00 2001 From: Ben Dwyer Date: Thu, 16 Feb 2023 09:54:32 +0000 Subject: [PATCH] Page List: Move the modal to its own file. (#47922) * Page List: Move modal to it's own file * Reorganize convert to links modal --------- Co-authored-by: Alex Lende --- .../src/page-list/convert-to-links-modal.js | 38 ++++++++++++++++ packages/block-library/src/page-list/edit.js | 43 +++++-------------- 2 files changed, 49 insertions(+), 32 deletions(-) create mode 100644 packages/block-library/src/page-list/convert-to-links-modal.js diff --git a/packages/block-library/src/page-list/convert-to-links-modal.js b/packages/block-library/src/page-list/convert-to-links-modal.js new file mode 100644 index 0000000000000..b212fccb77417 --- /dev/null +++ b/packages/block-library/src/page-list/convert-to-links-modal.js @@ -0,0 +1,38 @@ +/** + * WordPress dependencies + */ +import { Button, Modal } from '@wordpress/components'; +import { __ } from '@wordpress/i18n'; + +export const convertDescription = __( + 'This menu is automatically kept in sync with pages on your site. You can manage the menu yourself by clicking "Edit" below.' +); + +export function ConvertToLinksModal( { onClick, onClose, disabled } ) { + return ( + +

+ { convertDescription } +

+
+ + +
+
+ ); +} diff --git a/packages/block-library/src/page-list/edit.js b/packages/block-library/src/page-list/edit.js index 6b525960db224..876496686929a 100644 --- a/packages/block-library/src/page-list/edit.js +++ b/packages/block-library/src/page-list/edit.js @@ -23,7 +23,6 @@ import { Notice, ComboboxControl, Button, - Modal, } from '@wordpress/components'; import { __, sprintf } from '@wordpress/i18n'; import { useMemo, useState, useEffect } from '@wordpress/element'; @@ -34,16 +33,15 @@ import { useSelect } from '@wordpress/data'; * Internal dependencies */ import { useConvertToNavigationLinks } from './use-convert-to-navigation-links'; +import { + convertDescription, + ConvertToLinksModal, +} from './convert-to-links-modal'; // We only show the edit option when page count is <= MAX_PAGE_COUNT // Performance of Navigation Links is not good past this value. const MAX_PAGE_COUNT = 100; const NOOP = () => {}; - -const convertDescription = __( - 'This menu is automatically kept in sync with pages on your site. You can manage the menu yourself by clicking "Edit" below.' -); - function BlockContent( { blockProps, innerBlocksProps, @@ -113,7 +111,7 @@ function BlockContent( { } } -function ConvertToLinksModal( { onClick, disabled } ) { +function ConvertToLinks( { onClick, disabled } ) { const [ isOpen, setOpen ] = useState( false ); const openModal = () => setOpen( true ); const closeModal = () => setOpen( false ); @@ -126,30 +124,11 @@ function ConvertToLinksModal( { onClick, disabled } ) { { isOpen && ( - -

- { convertDescription } -

-
- - -
-
+ ) } ); @@ -344,7 +323,7 @@ export default function PageListEdit( { ) } { allowConvertToLinks && ( -