Skip to content

Commit

Permalink
rename var to shouldUseTemplateAsDefaultRenderingMode
Browse files Browse the repository at this point in the history
  • Loading branch information
ntsekouras committed Jul 1, 2024
1 parent 306fa3a commit 84e4464
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,38 +114,40 @@ function useNavigateToPreviousEntityRecord() {

export function useSpecificEditorSettings() {
const onNavigateToEntityRecord = useNavigateToEntityRecord();
const { templateSlug, canvasMode, settings, postWithTemplate } = useSelect(
( select ) => {
const {
getEditedPostType,
getEditedPostId,
getEditedPostContext,
getCanvasMode,
getSettings,
} = unlock( select( editSiteStore ) );
const { getEditedEntityRecord } = select( coreStore );
const usedPostType = getEditedPostType();
const usedPostId = getEditedPostId();
const _record = getEditedEntityRecord(
'postType',
usedPostType,
usedPostId
);
const _context = getEditedPostContext();
return {
templateSlug: _record.slug,
canvasMode: getCanvasMode(),
settings: getSettings(),
postWithTemplate:
// TODO: The `postType` check should be removed when the default rendering mode per post type is merged.
// @see https://github.com/WordPress/gutenberg/pull/62304/
_context?.postId && _context?.postType !== 'post',
};
},
[]
);
const {
templateSlug,
canvasMode,
settings,
shouldUseTemplateAsDefaultRenderingMode,
} = useSelect( ( select ) => {
const {
getEditedPostType,
getEditedPostId,
getEditedPostContext,
getCanvasMode,
getSettings,
} = unlock( select( editSiteStore ) );
const { getEditedEntityRecord } = select( coreStore );
const usedPostType = getEditedPostType();
const usedPostId = getEditedPostId();
const _record = getEditedEntityRecord(
'postType',
usedPostType,
usedPostId
);
const _context = getEditedPostContext();
return {
templateSlug: _record.slug,
canvasMode: getCanvasMode(),
settings: getSettings(),
// TODO: The `postType` check should be removed when the default rendering mode per post type is merged.
// @see https://github.com/WordPress/gutenberg/pull/62304/
shouldUseTemplateAsDefaultRenderingMode:
_context?.postId && _context?.postType !== 'post',
};
}, [] );
const archiveLabels = useArchiveLabel( templateSlug );
const defaultRenderingMode = postWithTemplate
const defaultRenderingMode = shouldUseTemplateAsDefaultRenderingMode
? 'template-locked'
: 'post-only';
const onNavigateToPreviousEntityRecord =
Expand Down
2 changes: 1 addition & 1 deletion packages/edit-site/src/components/editor/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ export default function EditSiteEditor( { isPostsList = false } ) {
onClick={ () => {
setCanvasMode( 'view' );
// TODO: this is a temporary solution to navigate to the posts list if we are
// come here throught `posts list` and are in focus mode editing a template or template part.
// come here through `posts list` and are in focus mode editing a template, template part etc..
if (
isPostsList &&
params?.focusMode
Expand Down

0 comments on commit 84e4464

Please sign in to comment.