Skip to content

Commit

Permalink
Fix: Capability to create pages is not taken into account on DataView…
Browse files Browse the repository at this point in the history
…s add new page button.
  • Loading branch information
jorgefilipecosta committed Jun 14, 2024
1 parent 854163b commit 053f278
Showing 1 changed file with 15 additions and 10 deletions.
25 changes: 15 additions & 10 deletions packages/edit-site/src/components/page-pages/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
() => [
Expand Down Expand Up @@ -496,7 +500,8 @@ export default function PagePages() {
<Page
title={ __( 'Pages' ) }
actions={
addNewLabel && (
addNewLabel &&
canCreatePage && (
<>
<Button
variant="primary"
Expand Down

0 comments on commit 053f278

Please sign in to comment.