2017-03-15 10:36:02 +08:00
|
|
|
|
import React from 'react';
|
|
|
|
|
import { T9n } from 'meteor/softwarerero:accounts-t9n';
|
|
|
|
|
import { hasPasswordService } from '../../helpers.js';
|
2017-03-23 12:50:49 +09:00
|
|
|
|
import { registerComponent } from 'meteor/nova:core';
|
2017-03-15 10:36:02 +08:00
|
|
|
|
|
2017-03-23 12:50:49 +09:00
|
|
|
|
export class AccountsPasswordOrService extends React.Component {
|
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 (
|
|
|
|
|
<div style={ style } className={ className }>
|
|
|
|
|
{ `${T9n.get('orUse')} ${ labels.join(' / ') }` }
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
2017-03-23 12:50:49 +09:00
|
|
|
|
AccountsPasswordOrService.propTypes = {
|
2017-03-15 10:36:02 +08:00
|
|
|
|
oauthServices: React.PropTypes.object
|
|
|
|
|
};
|
|
|
|
|
|
2017-03-23 12:50:49 +09:00
|
|
|
|
registerComponent('AccountsPasswordOrService', AccountsPasswordOrService);
|