Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ const disableTemplateWelcomeGuide = async () => {
};

const switchToTemplateMode = async () => {
await disableTemplateWelcomeGuide();

// Switch to template mode.
await openDocumentSettingsSidebar();
await openSidebarPanelWithTitle( 'Template' );
Expand All @@ -52,11 +54,11 @@ const switchToTemplateMode = async () => {
( el ) => el.innerText
);
expect( title ).toContain( 'About\n' );

await disableTemplateWelcomeGuide();
};

const createNewTemplate = async ( templateName ) => {
await disableTemplateWelcomeGuide();

// Create a new custom template.
await openDocumentSettingsSidebar();
await openSidebarPanelWithTitle( 'Template' );
Expand All @@ -76,8 +78,6 @@ const createNewTemplate = async ( templateName ) => {
await page.waitForXPath(
'//*[contains(@class, "components-snackbar")]/*[text()="Custom template created. You\'re in template mode now."]'
);

await disableTemplateWelcomeGuide();
};

describe( 'Post Editor Template mode', () => {
Expand Down
24 changes: 16 additions & 8 deletions packages/edit-post/src/store/actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -488,12 +488,20 @@ export function* __unstableSwitchToTemplateMode( template ) {

yield setIsEditingTemplate( true );

const message = !! template
? __( "Custom template created. You're in template mode now." )
: __(
'Editing template. Changes made here affect all posts and pages that use the template.'
);
yield controls.dispatch( noticesStore, 'createSuccessNotice', message, {
type: 'snackbar',
} );
const isWelcomeGuideActive = yield controls.select(
'core/edit-post',
'isFeatureActive',
'welcomeGuideTemplate'
);

if ( ! isWelcomeGuideActive ) {
const message = !! template
? __( "Custom template created. You're in template mode now." )
: __(
'Editing template. Changes made here affect all posts and pages that use the template.'
);
yield controls.dispatch( noticesStore, 'createSuccessNotice', message, {
type: 'snackbar',
} );
}
}