Skip to content

Commit

Permalink
Show template edit notice only if welcome guide isn’t active
Browse files Browse the repository at this point in the history
  • Loading branch information
stokesman committed Aug 24, 2024
1 parent e82e202 commit 6c4bc26
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions packages/editor/src/components/post-template/block-theme.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { __ } from '@wordpress/i18n';
import { useEntityRecord, store as coreStore } from '@wordpress/core-data';
import { check } from '@wordpress/icons';
import { store as noticesStore } from '@wordpress/notices';
import { store as preferencesStore } from '@wordpress/preferences';

/**
* Internal dependencies
Expand Down Expand Up @@ -43,6 +44,8 @@ export default function BlockThemeControl( { id } ) {
};
}, [] );

const { get: getPreference } = useSelect( preferencesStore );

const { editedRecord: template, hasResolved } = useEntityRecord(
'postType',
'wp_template',
Expand Down Expand Up @@ -75,6 +78,17 @@ export default function BlockThemeControl( { id } ) {
},
]
: undefined;

const mayShowTemplateEditNotice = () => {
if ( ! getPreference( 'core/edit-site', 'welcomeGuideTemplate' ) ) {
createSuccessNotice(
__(
'Editing template. Changes made here affect all posts and pages that use the template.'
),
{ type: 'snackbar', actions: notificationAction }
);
}
};
return (
<DropdownMenu
popoverProps={ POPOVER_PROPS }
Expand All @@ -99,15 +113,7 @@ export default function BlockThemeControl( { id } ) {
postType: 'wp_template',
} );
onClose();
createSuccessNotice(
__(
'Editing template. Changes made here affect all posts and pages that use the template.'
),
{
type: 'snackbar',
actions: notificationAction,
}
);
mayShowTemplateEditNotice();
} }
>
{ __( 'Edit template' ) }
Expand Down

0 comments on commit 6c4bc26

Please sign in to comment.