From e1a7aa9400f904dd6cde80bb08615d73d2c51bdc Mon Sep 17 00:00:00 2001 From: Sarah Norris Date: Wed, 27 Nov 2024 16:08:01 +0000 Subject: [PATCH] Refactor and remove renderModalBody --- .../post-actions/set-as-homepage.js | 50 +++++++------------ 1 file changed, 17 insertions(+), 33 deletions(-) diff --git a/packages/editor/src/components/post-actions/set-as-homepage.js b/packages/editor/src/components/post-actions/set-as-homepage.js index ad479b8f40dec9..0366a52482f2a8 100644 --- a/packages/editor/src/components/post-actions/set-as-homepage.js +++ b/packages/editor/src/components/post-actions/set-as-homepage.js @@ -80,39 +80,23 @@ const SetAsHomepageModal = ( { items, closeModal } ) => { } } - const renderModalBody = () => { - if ( 'posts' === showOnFront ) { - return ( - <> - - { sprintf( - // translators: %s: title of the page to be set as the homepage. - __( - 'Set "%s" as the site homepage? This will replace the current homepage which is set to display latest posts.' - ), - pageTitle - ) } - - - ); - } - - const modalTranslatedString = - // translators: %1$s: title of page to be set as the home page. %2$s: title of the current home page. - __( - 'Set "%1$s" as the site homepage? This will replace the current homepage: "%2$s"' - ); - - return ( - - { sprintf( - modalTranslatedString, - pageTitle, + const modalWarning = + 'posts' === showOnFront + ? __( + 'This will replace the current homepage which is set to display latest posts.' + ) + : sprintf( + // translators: %s: title of the current home page. + __( 'This will replace the current homepage: "%s"' ), currentHomePageTitle - ) } - - ); - }; + ); + + const modalText = sprintf( + // translators: %1$s: title of the page to be set as the homepage, %2$s: homepage replacement warning message. + __( 'Set "%1$s" as the site homepage? %2$s' ), + pageTitle, + modalWarning + ); // translators: Button label to confirm setting the specified page as the homepage. const modalButtonLabel = __( 'Set homepage' ); @@ -120,7 +104,7 @@ const SetAsHomepageModal = ( { items, closeModal } ) => { return (
- { renderModalBody() } + { modalText }