File size: 2,047 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
import {
	getPlan,
	JETPACK_RESET_PLANS,
	JETPACK_PRODUCTS_LIST,
	getJetpackProductShortName,
	getJetpackProductDescription,
	PRODUCTS_LIST,
} from '@automattic/calypso-products';
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component } from 'react';
import FormattedHeader from 'calypso/components/formatted-header';
import { FLOW_TYPES } from 'calypso/jetpack-connect/flow-types';

class JetpackConnectMainHeader extends Component {
	static propTypes = {
		type: PropTypes.oneOf( [ ...FLOW_TYPES, false ] ),
	};

	getTexts() {
		const { translate, type } = this.props;

		if ( type === 'install' ) {
			return {
				title: translate( 'Install Jetpack' ),
				subtitle: translate(
					'Jetpack brings free themes, security services, and essential marketing tools ' +
						'to your self-hosted WordPress site.'
				),
			};
		}

		if ( JETPACK_RESET_PLANS.includes( type ) ) {
			const plan = getPlan( type );

			if ( plan ) {
				return {
					title: translate( 'Get {{name/}}', {
						components: {
							name: <>{ plan.getTitle() }</>,
						},
						comment: '{{name/}} is the name of a plan',
					} ),
					subtitle: plan.getDescription(),
				};
			}
		}

		if ( JETPACK_PRODUCTS_LIST.includes( type ) ) {
			const product = PRODUCTS_LIST[ type ];

			if ( product ) {
				return {
					title: translate( 'Get {{name/}}', {
						components: {
							name: <>{ getJetpackProductShortName( product ) }</>,
						},
						comment: '{{name/}} is the name of a plan',
					} ),
					subtitle: getJetpackProductDescription( product ),
				};
			}
		}

		return {
			title: translate( 'Set up Jetpack on your self-hosted WordPress site' ),
			subtitle: translate(
				'The Jetpack plugin will be installed so WordPress.com can communicate with ' +
					'your self-hosted WordPress site.'
			),
		};
	}

	render() {
		const { title, subtitle } = this.getTexts();

		return <FormattedHeader headerText={ title } subHeaderText={ subtitle } />;
	}
}

export default localize( JetpackConnectMainHeader );