Skip to content

Commit

Permalink
feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgefilipecosta committed Dec 23, 2024
1 parent 6d146a7 commit 448e9be
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 17 additions & 1 deletion packages/core-data/src/private-selectors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,12 @@ import { createSelector, createRegistrySelector } from '@wordpress/data';
/**
* Internal dependencies
*/
import { getDefaultTemplateId, getEntityRecord, type State } from './selectors';
import {
canUser,
getDefaultTemplateId,
getEntityRecord,
type State,
} from './selectors';
import { STORE_NAME } from './name';
import { unlock } from './lock-unlock';

Expand Down Expand Up @@ -134,6 +139,13 @@ interface SiteData {
export const getHomePage = createRegistrySelector( ( select ) =>
createSelector(
() => {
const canReadSiteData = select( STORE_NAME ).canUser( 'read', {
kind: 'root',
name: 'site',
} );
if ( ! canReadSiteData ) {
return null;
}
const siteData = select( STORE_NAME ).getEntityRecord(
'root',
'site'
Expand All @@ -156,6 +168,10 @@ export const getHomePage = createRegistrySelector( ( select ) =>
return { postType: 'wp_template', postId: frontPageTemplateId };
},
( state ) => [
canUser( state, 'read', {
kind: 'root',
name: 'site',
} ),
getEntityRecord( state, 'root', 'site' ),
getDefaultTemplateId( state, {
slug: 'front-page',
Expand Down
5 changes: 0 additions & 5 deletions packages/edit-post/src/components/layout/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -400,10 +400,6 @@ function Layout( {
kind: 'postType',
name: 'wp_template',
} );
const canDiscoverTemplate = canUser( 'read', {
kind: 'root',
name: 'site',
} );
const { isZoomOut } = unlock( select( blockEditorStore ) );
const { getEditorMode, getRenderingMode } = select( editorStore );
const isRenderingPostOnly = getRenderingMode() === 'post-only';
Expand All @@ -425,7 +421,6 @@ function Layout( {
supportsTemplateMode &&
isViewable &&
canViewTemplate &&
canDiscoverTemplate &&
! isEditingTemplate
? getTemplateId( currentPostType, currentPostId )
: null,
Expand Down

0 comments on commit 448e9be

Please sign in to comment.