File size: 1,853 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 |
import { localize } from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component, Fragment } from 'react';
import { connect } from 'react-redux';
import QueryConnectedApplications from 'calypso/components/data/query-connected-applications';
import getConnectedApplications from 'calypso/state/selectors/get-connected-applications';
import SecurityCheckupNavigationItem from './navigation-item';
class SecurityCheckupConnectedApplications extends Component {
static propTypes = {
connectedApps: PropTypes.array,
translate: PropTypes.func.isRequired,
};
renderConnectedApplications() {
const { connectedApps, translate } = this.props;
let connectedAppsDescription;
if ( ! connectedApps.length ) {
connectedAppsDescription = translate( 'You do not have any connected applications.' );
} else {
connectedAppsDescription = translate(
'You currently have %(numberOfApps)d connected application.',
'You currently have %(numberOfApps)d connected applications.',
{
count: connectedApps.length,
args: {
numberOfApps: connectedApps.length,
},
}
);
}
return (
<SecurityCheckupNavigationItem
path="/me/security/connected-applications"
materialIcon="power"
materialIconStyle="filled"
text={ translate( 'Connected Apps' ) }
description={ connectedAppsDescription }
/>
);
}
render() {
const { connectedApps } = this.props;
let content;
if ( connectedApps === null ) {
content = <SecurityCheckupNavigationItem isPlaceholder />;
} else {
content = this.renderConnectedApplications();
}
return (
<Fragment>
<QueryConnectedApplications />
{ content }
</Fragment>
);
}
}
export default connect( ( state ) => ( {
connectedApps: getConnectedApplications( state ),
} ) )( localize( SecurityCheckupConnectedApplications ) );
|