1
0
mirror of https://github.com/ascribe/onion.git synced 2024-12-22 17:33:14 +01:00

Remove unused props in LoginForm

This commit is contained in:
Brett Sun 2016-01-11 18:07:52 +01:00
parent eafa675760
commit 58f57af932
3 changed files with 15 additions and 53 deletions

View File

@ -6,7 +6,6 @@ import { History } from 'react-router';
import GlobalNotificationModel from '../../models/global_notification_model'; import GlobalNotificationModel from '../../models/global_notification_model';
import GlobalNotificationActions from '../../actions/global_notification_actions'; import GlobalNotificationActions from '../../actions/global_notification_actions';
import UserStore from '../../stores/user_store';
import UserActions from '../../actions/user_actions'; import UserActions from '../../actions/user_actions';
import Form from './form'; import Form from './form';
@ -23,8 +22,6 @@ let LoginForm = React.createClass({
propTypes: { propTypes: {
headerMessage: React.PropTypes.string, headerMessage: React.PropTypes.string,
submitMessage: React.PropTypes.string, submitMessage: React.PropTypes.string,
redirectOnLoggedIn: React.PropTypes.bool,
redirectOnLoginSuccess: React.PropTypes.bool,
location: React.PropTypes.object location: React.PropTypes.object
}, },
@ -32,40 +29,24 @@ let LoginForm = React.createClass({
getDefaultProps() { getDefaultProps() {
return { return {
headerMessage: getLangText('Enter ascribe'), headerMessage: getLangText('Enter') + ' ascribe',
submitMessage: getLangText('Log in'), submitMessage: getLangText('Log in')
redirectOnLoggedIn: true,
redirectOnLoginSuccess: true
}; };
}, },
getInitialState() { handleSuccess({ success }) {
return UserStore.getState(); const notification = new GlobalNotificationModel('Login successful', 'success', 10000);
},
componentDidMount() {
UserStore.listen(this.onChange);
},
componentWillUnmount() {
UserStore.unlisten(this.onChange);
},
onChange(state) {
this.setState(state);
},
handleSuccess({ success }){
let notification = new GlobalNotificationModel('Login successful', 'success', 10000);
GlobalNotificationActions.appendGlobalNotification(notification); GlobalNotificationActions.appendGlobalNotification(notification);
if(success) { if (success) {
UserActions.fetchCurrentUser(true); UserActions.fetchCurrentUser(true);
} }
}, },
render() { render() {
let email = this.props.location.query.email || null; const { headerMessage, submitMessage, location: { query: { email: emailQuery } } } = this.props;
console.log(emailQuery);
return ( return (
<Form <Form
className="ascribe-form-bordered" className="ascribe-form-bordered"
@ -77,7 +58,7 @@ let LoginForm = React.createClass({
<button <button
type="submit" type="submit"
className="btn btn-default btn-wide"> className="btn btn-default btn-wide">
{this.props.submitMessage} {submitMessage}
</button>} </button>}
spinner={ spinner={
<span className="btn btn-default btn-wide btn-spinner"> <span className="btn btn-default btn-wide btn-spinner">
@ -85,7 +66,7 @@ let LoginForm = React.createClass({
</span> </span>
}> }>
<div className="ascribe-form-header"> <div className="ascribe-form-header">
<h3>{this.props.headerMessage}</h3> <h3>{headerMessage}</h3>
</div> </div>
<Property <Property
name='email' name='email'
@ -93,7 +74,7 @@ let LoginForm = React.createClass({
<input <input
type="email" type="email"
placeholder={getLangText('Enter your email')} placeholder={getLangText('Enter your email')}
defaultValue={email} defaultValue={emailQuery}
required/> required/>
</Property> </Property>
<Property <Property

View File

@ -11,11 +11,6 @@ import { setDocumentTitle } from '../utils/dom_utils';
let LoginContainer = React.createClass({ let LoginContainer = React.createClass({
propTypes: { propTypes: {
message: React.PropTypes.string,
redirectOnLoggedIn: React.PropTypes.bool,
redirectOnLoginSuccess: React.PropTypes.bool,
onLogin: React.PropTypes.func,
// Provided from AscribeApp // Provided from AscribeApp
currentUser: React.PropTypes.object, currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object, whitelabel: React.PropTypes.object,
@ -24,25 +19,12 @@ let LoginContainer = React.createClass({
location: React.PropTypes.object location: React.PropTypes.object
}, },
getDefaultProps() {
return {
message: getLangText('Enter') + ' ascribe',
redirectOnLoggedIn: true,
redirectOnLoginSuccess: true
};
},
render() { render() {
setDocumentTitle(getLangText('Log in')); setDocumentTitle(getLangText('Log in'));
return ( return (
<div className="ascribe-login-wrapper"> <div className="ascribe-login-wrapper">
<LoginForm <LoginForm location={this.props.location} />
redirectOnLoggedIn={this.props.redirectOnLoggedIn}
redirectOnLoginSuccess={this.props.redirectOnLoginSuccess}
message={this.props.message}
onLogin={this.props.onLogin}
location={this.props.location}/>
<div className="ascribe-login-text"> <div className="ascribe-login-text">
{getLangText('Not an ascribe user')}&#63; <Link to="/signup">{getLangText('Sign up')}...</Link><br/> {getLangText('Not an ascribe user')}&#63; <Link to="/signup">{getLangText('Sign up')}...</Link><br/>
{getLangText('Forgot my password')}&#63; <Link to="/password_reset">{getLangText('Rescue me')}...</Link> {getLangText('Forgot my password')}&#63; <Link to="/password_reset">{getLangText('Rescue me')}...</Link>

View File

@ -26,12 +26,11 @@ let LoginContainer = React.createClass({
<div className="ascribe-login-wrapper"> <div className="ascribe-login-wrapper">
<LoginForm <LoginForm
headerMessage={getLangText('Log in with ascribe')} headerMessage={getLangText('Log in with ascribe')}
location={this.props.location}/> location={this.props.location} />
<div <div className="ascribe-login-text">
className="ascribe-login-text">
{getLangText('I\'m not a user') + ' '} {getLangText('I\'m not a user') + ' '}
<Link to="/signup">{getLangText('Sign up...')}</Link> <Link to="/signup">{getLangText('Sign up...')}</Link>
<br/> <br />
{getLangText('I forgot my password') + ' '} {getLangText('I forgot my password') + ' '}
<Link to="/password_reset">{getLangText('Rescue me...')}</Link> <Link to="/password_reset">{getLangText('Rescue me...')}</Link>