Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make sure expression before && is always boolean in React rendering in marketing page #37227

Merged
merged 2 commits into from Mar 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -64,7 +64,7 @@ const CollapsibleCard: React.FC< CollapsibleCardProps > = ( {
{ ! collapsed && (
<>
{ children }
{ footer && <CardFooter>{ footer }</CardFooter> }
{ !! footer && <CardFooter>{ footer }</CardFooter> }
</>
) }
</Card>
Expand Down
Expand Up @@ -79,7 +79,7 @@ const KnowledgeBase = ( {
target="_blank"
rel="noopener noreferrer"
>
{ post.image && (
{ !! post.image && (
<div className="woocommerce-marketing-knowledgebase-card__post-img">
<img src={ post.image } alt="" />
</div>
Expand All @@ -89,7 +89,7 @@ const KnowledgeBase = ( {
<p className="woocommerce-marketing-knowledgebase-card__post-meta">
{ __( 'By', 'woocommerce' ) + ' ' }
{ post.author_name }
{ post.author_avatar && (
{ !! post.author_avatar && (
<img
src={ post.author_avatar.replace(
's=96',
Expand Down
Expand Up @@ -22,7 +22,7 @@ const CouponsOverview = () => {

return (
<div className="woocommerce-marketing-coupons">
{ shouldShowExtensions && (
{ !! shouldShowExtensions && (
<RecommendedExtensions
title={ __(
'Recommended coupon extensions',
Expand Down
Expand Up @@ -139,7 +139,7 @@ export const Campaigns = () => {
{ el.title }
</Link>
</FlexItem>
{ el.description && (
{ !! el.description && (
<FlexItem className="woocommerce-marketing-campaigns-card__campaign-description">
{ el.description }
</FlexItem>
Expand Down Expand Up @@ -168,14 +168,14 @@ export const Campaigns = () => {
>
{ __( 'Create new campaign', 'woocommerce' ) }
</Button>
{ isModalOpen && (
{ !! isModalOpen && (
<CreateNewCampaignModal
onRequestClose={ () => setModalOpen( false ) }
/>
) }
</CardHeader>
{ getContent() }
{ total && total > perPage && (
{ !! ( total && total > perPage ) && (
<CardFooter className="woocommerce-marketing-campaigns-card__footer">
<Pagination
showPerPagePicker={ false }
Expand Down
Expand Up @@ -105,7 +105,7 @@ export const CreateNewCampaignModal = ( props: CreateCampaignModalProps ) => {
<FlexItem>
{ __( 'Create', 'woocommerce' ) }
</FlexItem>
{ isExternalURL( el.createUrl ) && (
{ !! isExternalURL( el.createUrl ) && (
<FlexItem>
<Icon
icon={ external }
Expand Down
Expand Up @@ -76,7 +76,7 @@ export const Channels: React.FC< ChannelsProps > = ( {
{ /* Recommended channels section. */ }
{ recommendedChannels.length >= 1 && (
<div>
{ hasRegisteredChannels && (
{ !! hasRegisteredChannels && (
<>
<CardDivider />
<CardBody>
Expand All @@ -95,7 +95,7 @@ export const Channels: React.FC< ChannelsProps > = ( {
</CardBody>
</>
) }
{ expanded &&
{ !! expanded &&
recommendedChannels.map( ( el, idx ) => {
return (
<Fragment key={ el.plugin }>
Expand Down
Expand Up @@ -31,7 +31,7 @@ export const RegisteredChannelCardBody: React.FC<
registeredChannel.description
) : (
<div className="woocommerce-marketing-registered-channel-description">
{ registeredChannel.syncStatus && (
{ !! registeredChannel.syncStatus && (
<>
<SyncStatus status={ registeredChannel.syncStatus } />
<div className="woocommerce-marketing-registered-channel-description__separator" />
Expand Down
Expand Up @@ -27,7 +27,7 @@ export const PostTile: React.FC< PostTileProps > = ( { post } ) => {
} }
>
<div className="woocommerce-marketing-learn-marketing-card__post-img">
{ post.image && <img src={ post.image } alt="" /> }
{ !! post.image && <img src={ post.image } alt="" /> }
</div>
<div className="woocommerce-marketing-learn-marketing-card__post-title">
{ post.title }
Expand All @@ -37,7 +37,7 @@ export const PostTile: React.FC< PostTileProps > = ( { post } ) => {
// translators: %s: author's name.
sprintf( __( 'By %s', 'woocommerce' ), post.author_name )
}
{ post.author_avatar && (
{ !! post.author_avatar && (
<img
src={ post.author_avatar.replace( 's=96', 's=32' ) }
alt=""
Expand Down
Expand Up @@ -57,8 +57,7 @@ export const MarketingOverviewMultichannel: React.FC = () => {
return (
<div className="woocommerce-marketing-overview-multichannel">
{ !! dataRegistered?.length && <Campaigns /> }
{ dataRegistered &&
dataRecommended &&
{ !! ( dataRegistered && dataRecommended ) &&
!! ( dataRegistered.length || dataRecommended.length ) && (
<Channels
registeredChannels={ dataRegistered }
Expand All @@ -67,7 +66,7 @@ export const MarketingOverviewMultichannel: React.FC = () => {
/>
) }
<InstalledExtensions />
{ shouldShowExtensions && <DiscoverTools /> }
{ !! shouldShowExtensions && <DiscoverTools /> }
<LearnMarketing />
</div>
);
Expand Down
Expand Up @@ -27,7 +27,7 @@ const MarketingOverview = () => {
<WelcomeCard />
<InstalledExtensions />
<MarketingOverviewSectionSlot />
{ shouldShowExtensions && (
{ !! shouldShowExtensions && (
<RecommendedExtensions category="marketing" />
) }
<KnowledgeBase category="marketing" />
Expand Down
@@ -0,0 +1,4 @@
Significance: patch
Type: fix

Fix React rendering falsy value in marketing page.