From aa1cc8d1b69c8d48437b4483ad6d40689f80d01a Mon Sep 17 00:00:00 2001 From: Jorge Costa Date: Tue, 18 Jun 2024 13:01:55 +0200 Subject: [PATCH 01/12] Fix: Check Capability to create pages on DataViews add new page button (#62592) Co-authored-by: jorgefilipecosta Co-authored-by: carolinan --- .../src/components/page-pages/index.js | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/packages/edit-site/src/components/page-pages/index.js b/packages/edit-site/src/components/page-pages/index.js index 0fa8a8d7e9b565..55edb056dc0523 100644 --- a/packages/edit-site/src/components/page-pages/index.js +++ b/packages/edit-site/src/components/page-pages/index.js @@ -277,15 +277,19 @@ export default function PagePages() { [ totalItems, totalPages ] ); - const { frontPageId, postsPageId, addNewLabel } = useSelect( ( select ) => { - const { getEntityRecord, getPostType } = select( coreStore ); - const siteSettings = getEntityRecord( 'root', 'site' ); - return { - frontPageId: siteSettings?.page_on_front, - postsPageId: siteSettings?.page_for_posts, - addNewLabel: getPostType( 'page' )?.labels?.add_new_item, - }; - } ); + const { frontPageId, postsPageId, addNewLabel, canCreatePage } = useSelect( + ( select ) => { + const { getEntityRecord, getPostType, canUser } = + select( coreStore ); + const siteSettings = getEntityRecord( 'root', 'site' ); + return { + frontPageId: siteSettings?.page_on_front, + postsPageId: siteSettings?.page_for_posts, + addNewLabel: getPostType( 'page' )?.labels?.add_new_item, + canCreatePage: canUser( 'create', 'pages' ), + }; + } + ); const fields = useMemo( () => [ @@ -499,7 +503,8 @@ export default function PagePages() {