File size: 1,503 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
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component } from 'react';
import { connect } from 'react-redux';
import { getCurrentUser } from 'calypso/state/current-user/selectors';
import SecurityCheckupNavigationItem from './navigation-item';

class SecurityCheckupSocialLogins extends Component {
	static propTypes = {
		socialConnectionCount: PropTypes.number.isRequired,
		translate: PropTypes.func.isRequired,
	};

	render() {
		const { socialConnectionCount, translate } = this.props;

		let description;

		if ( socialConnectionCount === 0 ) {
			description = translate( 'You do not have any social logins enabled.' );
		} else {
			description = translate(
				'You have {{strong}}%(socialLoginCount)d social login enabled{{/strong}}.',
				'You have {{strong}}%(socialLoginCount)d social logins enabled{{/strong}}.',
				{
					count: socialConnectionCount,
					args: {
						socialLoginCount: socialConnectionCount,
					},
					components: {
						strong: <strong />,
					},
				}
			);
		}

		return (
			<SecurityCheckupNavigationItem
				description={ description }
				materialIcon="person"
				path="/me/security/social-login"
				text={ translate( 'Social Logins' ) }
			/>
		);
	}
}

export default connect( ( state ) => {
	const currentUser = getCurrentUser( state );
	const connections = currentUser.social_login_connections || [];
	return {
		socialConnectionCount: connections.length,
	};
} )( localize( SecurityCheckupSocialLogins ) );