Back

90.9% Statements 10/11
87.5% Branches 7/8
100% Functions 1/1
90.9% Lines 10/11

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60                            4x           4x 1x       1x 3x 1x       1x     2x                 2x     4x                          
import { __ } from '@wordpress/i18n';
import { shield } from '@wordpress/icons';
import { Link, Stack, Text } from '@wordpress/ui';
import { CardRow, ProtectCard } from '../../components/card';
import type { ScanContext } from './types';
 
/**
 * The Settings tab's Scan card: links to the server credentials Auto-fix needs, or to Scan without a plan.
 *
 * @param props       - The dashboard context.
 * @param props.state - The Scan section's state.
 * @return The card.
 */
export default function ScanSettingsCard( { state: scan }: ScanContext ) {
	Iif ( ! scan ) {
		return null;
	}
 
	let description: string;
	let link: string;
	if ( ! scan.hasPlan ) {
		description = __(
			'Your site is checked every day for known vulnerabilities in WordPress, plugins and themes. There’s nothing to set up.',
			'jetpack-protect-pkg'
		);
		link = __( 'Get Scan for daily malware scanning and one-click fixes', 'jetpack-protect-pkg' );
	} else if ( scan.hasCredentials === false ) {
		description = __(
			'Scan checks your site for malware every day. Auto-fix needs your server credentials to repair threats.',
			'jetpack-protect-pkg'
		);
		link = __( 'Add server credentials', 'jetpack-protect-pkg' );
	} else {
		// Null means no report to go by, so don't claim credentials are on file.
		description = scan.hasCredentials
			? __(
					'Scan checks your site for malware every day. Auto-fix uses your server credentials to repair threats.',
					'jetpack-protect-pkg'
				)
			: __(
					'Scan checks your site for malware every day. Auto-fix uses server credentials to repair threats.',
					'jetpack-protect-pkg'
				);
		link = __( 'Manage server credentials', 'jetpack-protect-pkg' );
	}
 
	return (
		<ProtectCard icon={ shield } title={ __( 'Scan', 'jetpack-protect-pkg' ) }>
			<CardRow>
				<Stack direction="column" gap="sm">
					<Text variant="body-md">{ description }</Text>
					<Link href={ scan.url } openInNewTab={ scan.hasPlan }>
						{ link }
					</Link>
				</Stack>
			</CardRow>
		</ProtectCard>
	);
}