2017-05-19 14:42:43 -06:00
|
|
|
import React, { PureComponent } from 'react';
|
|
|
|
import PropTypes from 'prop-types';
|
2017-03-15 10:36:02 +08:00
|
|
|
import { hasPasswordService } from '../../helpers.js';
|
2017-03-23 16:27:59 +09:00
|
|
|
import { registerComponent } from 'meteor/vulcan:core';
|
2017-06-01 11:42:30 +09:00
|
|
|
import { intlShape } from 'meteor/vulcan:i18n';
|
2017-03-15 10:36:02 +08:00
|
|
|
|
2017-05-19 14:42:43 -06:00
|
|
|
export class AccountsPasswordOrService extends PureComponent {
|
2017-03-15 10:36:02 +08:00
|
|
|
render () {
|
|
|
|
let { className = "password-or-service", style = {} } = this.props;
|
2017-03-15 13:47:25 +08:00
|
|
|
const services = Object.keys(this.props.oauthServices).map(service => {
|
|
|
|
return this.props.oauthServices[service].label;
|
|
|
|
});
|
|
|
|
let labels = services;
|
2017-03-15 10:36:02 +08:00
|
|
|
if (services.length > 2) {
|
|
|
|
labels = [];
|
|
|
|
}
|
|
|
|
|
2017-03-15 13:47:25 +08:00
|
|
|
if (hasPasswordService() && services.length > 0) {
|
2017-03-15 10:36:02 +08:00
|
|
|
return (
|
2018-01-25 15:03:03 -06:00
|
|
|
<div style={style} className={className}>
|
2017-03-23 13:43:04 +09:00
|
|
|
{ `${this.context.intl.formatMessage({id: 'accounts.or_use'})} ${ labels.join(' / ') }` }
|
2017-03-15 10:36:02 +08:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
2017-03-23 13:43:04 +09:00
|
|
|
|
2017-03-23 12:50:49 +09:00
|
|
|
AccountsPasswordOrService.propTypes = {
|
2017-05-19 14:42:43 -06:00
|
|
|
oauthServices: PropTypes.object
|
2017-03-15 10:36:02 +08:00
|
|
|
};
|
|
|
|
|
2017-03-23 13:43:04 +09:00
|
|
|
AccountsPasswordOrService.contextTypes = {
|
|
|
|
intl: intlShape
|
2017-05-19 14:42:43 -06:00
|
|
|
};
|
2017-03-23 13:43:04 +09:00
|
|
|
|
2017-03-23 12:50:49 +09:00
|
|
|
registerComponent('AccountsPasswordOrService', AccountsPasswordOrService);
|