Vulcan/packages/nova-base-components/lib/users/UsersAccountForm.jsx
Comus Leong 464e20a96c eslint & clean up code, also fixed some bugs (#1515)
* [eslint] update eslint rules & add .eslintignore to ignore non-ready nova packages

* [clean-up] nova-voting

* [clean-up] [bug] nova-users: missing user parameter

* [clean-up] nova-users

* [clean-up] nova-subscribe

* [clean-up] nova-settings

* [clean-up] nova-rss

* [clean-up] [bug] nova-posts: correct UsersRemoveDeletePosts

* [clean-up] nova-posts

* [clean-up] nova-notifications

* [clean-up] [bug] nova-newsletter: no error.message on throw error

* [clean-up] nova-newsletter

* [clean-up] nova-lib

* [clean-up] nova-kadira

* [clean-up] nova-inject-data

* [clean-up] nova-getting-started

* [clean-up] nova-forms

* [clean-up] nova-events

* [clean-up] [bug] nova-embedly: no FlowRouter

* [clean-up] nova-embedly

* [clean-up] nova-email-templates

* [clean-up] nova-email

* [clean-up] nova-debug

* [clean-up] nova-core

* [clean-up] [bug] nova-comments: correct UsersRemoveDeleteComments

* [clean-up] nova-comments

* [clean-up] [bug] nova-cloudinary: use Telescope.settings.collection instand

* [clean-up] nova-cloudinary

* [clean-up] nova-categories

* [clean-up] nova-base-components

* [clean-up] nova-api

* [eslint] extends react recommended

* [clean-up] for jsx files

* [eslint] extends meteor recommended

* i forgot this one little change
2016-11-25 13:46:55 -05:00

102 lines
3 KiB
JavaScript

import React, { PropTypes, Component } from 'react';
import { Button, FormControl } from 'react-bootstrap';
import { Accounts } from 'meteor/std:accounts-ui';
const UsersAccountForm = () => {
return (
<Accounts.ui.LoginForm />
)
};
module.exports = UsersAccountForm;
export default UsersAccountForm;
// customize Accounts.ui
Accounts.ui.config({
passwordSignupFields: 'USERNAME_AND_EMAIL',
onSignedInHook: () => {},
onSignedOutHook: () => {},
});
class AccountsButton extends Accounts.ui.Button {
render () {
const {label, href, type, disabled, className, onClick} = this.props;
if (type === 'link') {
return <a href={ href } className={ className } onClick={ onClick }>{ label }</a>;
}
return <Button
bsStyle="primary"
className={ className }
type={ type }
disabled={ disabled }
onClick={ onClick }>{ label }
</Button>;
}
}
class AccountsField extends Accounts.ui.Field {
// see https://github.com/studiointeract/accounts-ui/issues/60
triggerUpdate () {
const { onChange } = this.props
if (this.input) {
onChange({ target: { value: this.input.value } })
}
}
render() {
const { id, hint, /* label, */ type = 'text', onChange, className = "field", defaultValue = "" } = this.props;
const { mount = true } = this.state;
return mount ? (
<div className={ className }>
<FormControl id={ id } type={ type } onChange={ onChange } placeholder={ hint } defaultValue={ defaultValue } />
</div>
) : null;
}
}
// class AccountsSocialButtons extends Accounts.ui.SocialButtons {
// render () {
// let { oauthServices = {}, className = "social_buttons" } = this.props;
// return(
// <div className={ className }>
// {Object.keys(oauthServices)
// .filter(service => oauthServices[service].disabled) // filter services registered but not enabled
// .map((id, i) => <Accounts.ui.Button {...oauthServices[id]} key={i} />)}
// </div>
// );
// }
// }
// class AccountsPasswordOrService extends Accounts.ui.PasswordOrService {
// render () {
// let {
// oauthServices = {},
// className,
// style = {}
// } = this.props;
// let { hasPasswordService } = this.state;
// let labels = Object.keys(oauthServices)
// .filter(service => oauthServices[service].disabled) // filter services registered but not enabled
// .map(service => oauthServices[service].label);
// if (labels.length > 2) {
// labels = [];
// }
// if (hasPasswordService && labels.length > 0) {
// return (
// <div style={ style } className={ className }>
// { `${T9n.get('or use')} ${ labels.join(' / ') }` }
// </div>
// );
// }
// return null;
// }
// }
Accounts.ui.Button = AccountsButton;
Accounts.ui.Field = AccountsField;
// Accounts.ui.SocialButtons = AccountsSocialButtons;
// Accounts.ui.PasswordOrService = AccountsPasswordOrService;