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

Protect: Refactor AdminSectionHero #40516

Merged
merged 6 commits into from
Dec 9, 2024
Merged
Changes from 1 commit
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
@@ -1,7 +1,7 @@
import { Text, Button, useBreakpointMatch } from '@automattic/jetpack-components';
import { Tooltip } from '@wordpress/components';
import { dateI18n } from '@wordpress/date';
import { __, _n, sprintf } from '@wordpress/i18n';
import { __, sprintf } from '@wordpress/i18n';
import { useCallback, useState } from 'react';
import { useMemo } from 'react';
import AdminSectionHero from '../../components/admin-section-hero';
Expand Down Expand Up @@ -59,6 +59,23 @@ const ScanAdminSectionHero: React.FC = () => {
lastCheckedLocalTimestamp = new Date( status.lastChecked + ' UTC' ).getTime();
}

let heading = __( "Don't worry about a thing", 'jetpack-protect' );
if ( numThreats > 0 ) {
if ( hasPlan ) {
heading = sprintf(
/* translators: %s: Total number of threats */
__( '%1$s active threats', 'jetpack-protect' ),
nateweller marked this conversation as resolved.
Show resolved Hide resolved
numThreats
);
} else {
heading = sprintf(
/* translators: %s: Total number of vulnerabilities */
__( '%1$s active vulnerabilities', 'jetpack-protect' ),
numThreats
);
}
}

const handleShowAutoFixersClick = threatList => {
return event => {
event.preventDefault();
Expand Down Expand Up @@ -101,16 +118,7 @@ const ScanAdminSectionHero: React.FC = () => {
anchor={ dailyScansPopoverAnchor }
/>
<AdminSectionHero.Heading icon={ numThreats > 0 ? 'error' : 'success' }>
{ numThreats > 0
? sprintf(
/* translators: %s: Total number of threats/vulnerabilities */
__( '%1$s active %2$s', 'jetpack-protect' ),
numThreats,
hasPlan
? _n( 'threat', 'threats', numThreats, 'jetpack-protect' )
: _n( 'vulnerability', 'vulnerabilities', numThreats, 'jetpack-protect' )
)
: __( "Don't worry about a thing", 'jetpack-protect' ) }
{ heading }
</AdminSectionHero.Heading>
{ hasPlan ? (
<Text>
Expand Down
Loading