Skip to content

Commit

Permalink
enhacements
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Jul 11, 2024
1 parent 1444714 commit c1f467b
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 9 deletions.
5 changes: 4 additions & 1 deletion packages/edit-post/src/store/private-selectors.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export const getEditedPostTemplateId = createRegistrySelector(
slug,
} = select( editorStore ).getCurrentPost();
const { getSite, getEntityRecords, canUser } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getSite()
: undefined;
// First check if the current page is set as the posts page.
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/blog-title/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ export default function BlogTitle() {
( select ) => {
const { getEntityRecord, getEditedEntityRecord, canUser } =
select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEntityRecord( 'root', 'site' )
: undefined;
const _postsPageRecord = siteSettings?.page_for_posts
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/post-card-panel/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,10 @@ export default function PostCardPanel( { actions } ) {
} = select( editorStore );
const { canUser } = select( coreStore );
const { getEditedEntityRecord } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEditedEntityRecord( 'root', 'site' )
: undefined;
const _type = getCurrentPostType();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,10 @@ export default function PostContentInformation() {
select( editorStore );
const { canUser } = select( coreStore );
const { getEntityRecord } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEntityRecord( 'root', 'site' )
: undefined;
const postType = getCurrentPostType();
Expand Down
10 changes: 8 additions & 2 deletions packages/editor/src/components/post-template/hooks.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,14 @@ export function useAllowSwitchingTemplates() {
const { postType, postId } = useEditedPostContext();
return useSelect(
( select ) => {
const { getEntityRecord, getEntityRecords } = select( coreStore );
const siteSettings = getEntityRecord( 'root', 'site' );
const { canUser, getEntityRecord, getEntityRecords } =
select( coreStore );
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEntityRecord( 'root', 'site' )
: undefined;
const templates = getEntityRecords( 'postType', 'wp_template', {
per_page: -1,
} );
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/post-url/panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,10 @@ function PostURLToggle( { isOpen, onClick } ) {
const { slug, isFrontPage, postLink } = useSelect( ( select ) => {
const { getCurrentPostId, getCurrentPost } = select( editorStore );
const { getEditedEntityRecord, canUser } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEditedEntityRecord( 'root', 'site' )
: undefined;
const _id = getCurrentPostId();
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/posts-per-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,10 @@ export default function PostsPerPage() {
const { getEditedPostAttribute, getCurrentPostType } =
select( editorStore );
const { getEditedEntityRecord, canUser } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEditedEntityRecord( 'root', 'site' )
: undefined;
return {
Expand Down
5 changes: 4 additions & 1 deletion packages/editor/src/components/site-discussion/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export default function SiteDiscussion() {
const { getEditedPostAttribute, getCurrentPostType } =
select( editorStore );
const { getEditedEntityRecord, canUser } = select( coreStore );
const siteSettings = canUser( 'read', 'settings' )
const siteSettings = canUser( 'read', {
kind: 'root',
name: 'site',
} )
? getEditedEntityRecord( 'root', 'site' )
: undefined;
return {
Expand Down

0 comments on commit c1f467b

Please sign in to comment.