Back

100% Statements 8/8
100% Branches 2/2
100% Functions 1/1
100% Lines 8/8

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 61 62 63                3x 6x   6x                                               6x   6x   6x 6x                               3x            
import { getRedirectUrl } from '@automattic/jetpack-components';
import { __ } from '@wordpress/i18n';
import { Link } from '@wordpress/ui';
import PropTypes from 'prop-types';
import { getProductGroup } from '../../activation-screen/utils';
 
import './style.scss';
 
const ProductLink = props => {
	const { productId, siteRawUrl } = props;
 
	const productLinkMap = {
		jetpack_backup: {
			text: __( 'View latest backup', 'jetpack-licensing' ),
			redirectSource: 'jetpack-license-activation-success-backup',
		},
		jetpack_complete: {
			text: __( 'View latest backup', 'jetpack-licensing' ),
			redirectSource: 'jetpack-license-activation-success-backup',
		},
		jetpack_scan: {
			text: __( 'View my plans', 'jetpack-licensing' ),
			redirectSource: 'license-activation-view-my-plans',
		},
		jetpack_search: {
			text: __( 'Configure search', 'jetpack-licensing' ),
			redirectSource: 'jetpack-license-activation-success-search',
		},
		jetpack_security: {
			text: __( 'View latest backup', 'jetpack-licensing' ),
			redirectSource: 'jetpack-license-activation-success-backup',
		},
		default: null,
	};
 
	productLinkMap.jetpack_pro = productLinkMap.jetpack_complete;
 
	const productGroup = getProductGroup( productId );
 
	const productLink = productLinkMap[ productGroup ];
	return (
		<>
			{ productLink && (
				<Link
					openInNewTab
					rel="noopener noreferrer"
					className="jp-license-activation-screen-success-info--external-link"
					href={ getRedirectUrl( productLink.redirectSource, { site: siteRawUrl } ) }
				>
					{ productLink.text }
				</Link>
			) }
		</>
	);
};
 
ProductLink.propTypes = {
	siteRawUrl: PropTypes.string,
	productId: PropTypes.number,
};
 
export { ProductLink };