Skip to content

Commit

Permalink
Refactor and remove renderModalBody
Browse files Browse the repository at this point in the history
  • Loading branch information
mikachan committed Nov 27, 2024
1 parent 8bacdbb commit e1a7aa9
Showing 1 changed file with 17 additions and 33 deletions.
50 changes: 17 additions & 33 deletions packages/editor/src/components/post-actions/set-as-homepage.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,47 +80,31 @@ const SetAsHomepageModal = ( { items, closeModal } ) => {
}
}

const renderModalBody = () => {
if ( 'posts' === showOnFront ) {
return (
<>
<Text>
{ 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
) }
</Text>
</>
);
}

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 (
<Text>
{ 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
) }
</Text>
);
};
);

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' );

return (
<form onSubmit={ onSetPageAsHomepage }>
<VStack spacing="5">
{ renderModalBody() }
<Text>{ modalText }</Text>
<HStack justify="right">
<Button
__next40pxDefaultSize
Expand Down

0 comments on commit e1a7aa9

Please sign in to comment.