From 09c0e9ef81089b39bfddfd4675046058a790ae19 Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Fri, 21 May 2021 08:27:25 +0400 Subject: [PATCH 1/2] Template Mode: Don't display snackbar with the Welcome Guide --- packages/edit-post/src/store/actions.js | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/packages/edit-post/src/store/actions.js b/packages/edit-post/src/store/actions.js index a5cbb195ad1f2a..ba847625c4d49e 100644 --- a/packages/edit-post/src/store/actions.js +++ b/packages/edit-post/src/store/actions.js @@ -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', + } ); + } } From 3a00dc01e3732ac6b821d076fda60823be453eee Mon Sep 17 00:00:00 2001 From: George Mamadashvili Date: Sat, 22 May 2021 11:38:00 +0400 Subject: [PATCH 2/2] Fix e2e tests --- .../specs/experiments/post-editor-template-mode.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js index b2122c946d3fba..1135441dfbad57 100644 --- a/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js +++ b/packages/e2e-tests/specs/experiments/post-editor-template-mode.test.js @@ -35,6 +35,8 @@ const disableTemplateWelcomeGuide = async () => { }; const switchToTemplateMode = async () => { + await disableTemplateWelcomeGuide(); + // Switch to template mode. await openDocumentSettingsSidebar(); await openSidebarPanelWithTitle( 'Template' ); @@ -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' ); @@ -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', () => {