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

View File

@ -11,11 +11,6 @@ import { setDocumentTitle } from '../utils/dom_utils';
let LoginContainer = React.createClass({
propTypes: {
message: React.PropTypes.string,
redirectOnLoggedIn: React.PropTypes.bool,
redirectOnLoginSuccess: React.PropTypes.bool,
onLogin: React.PropTypes.func,
// Provided from AscribeApp
currentUser: React.PropTypes.object,
whitelabel: React.PropTypes.object,
@ -24,25 +19,12 @@ let LoginContainer = React.createClass({
location: React.PropTypes.object
},
getDefaultProps() {
return {
message: getLangText('Enter') + ' ascribe',
redirectOnLoggedIn: true,
redirectOnLoginSuccess: true
};
},
render() {
setDocumentTitle(getLangText('Log in'));
return (
<div className="ascribe-login-wrapper">
<LoginForm
redirectOnLoggedIn={this.props.redirectOnLoggedIn}
redirectOnLoginSuccess={this.props.redirectOnLoginSuccess}
message={this.props.message}
onLogin={this.props.onLogin}
location={this.props.location}/>
<LoginForm location={this.props.location} />
<div className="ascribe-login-text">
{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>

View File

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