diff --git a/plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js b/plugins/coral-plugin-auth/client/components/ChangeUsername.js similarity index 69% rename from plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js rename to plugins/coral-plugin-auth/client/components/ChangeUsername.js index 4f0ad9895..9b0cbb1a6 100644 --- a/plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js +++ b/plugins/coral-plugin-auth/client/components/ChangeUsername.js @@ -1,13 +1,12 @@ -import React, {Component} from 'react'; +import React from 'react'; import {connect} from 'react-redux'; - -import validate from 'coral-framework/helpers/validate'; +import {bindActionCreators} from 'redux'; +import translations from '../translations'; +import I18n from 'coral-framework/modules/i18n/i18n'; import errorMsj from 'coral-framework/helpers/error'; - +import validate from 'coral-framework/helpers/validate'; import CreateUsernameDialog from './CreateUsernameDialog'; -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; const lang = new I18n(translations); import { @@ -18,26 +17,20 @@ import { createUsername } from 'coral-framework/actions/auth'; -class ChangeUsernameContainer extends Component { - initialState = { - formData: { - username: '' - }, - errors: {}, - showErrors: false - }; - +class ChangeUsernameContainer extends React.Component { constructor(props) { super(props); - this.initialState.formData.username = props.user.username; - this.state = this.initialState; - this.handleChange = this.handleChange.bind(this); - this.handleSubmitUsername = this.handleSubmitUsername.bind(this); - this.handleClose = this.handleClose.bind(this); - this.addError = this.addError.bind(this); + + this.state = { + formData: { + username: props.user.username + }, + errors: {}, + showErrors: false + }; } - handleChange(e) { + handleChange = e => { const {name, value} = e.target; this.setState( state => ({ @@ -51,18 +44,18 @@ class ChangeUsernameContainer extends Component { this.validation(name, value); } ); - } + }; - addError(name, error) { + addError = (name, error) => { return this.setState(state => ({ errors: { ...state.errors, [name]: error } })); - } + }; - validation(name, value) { + validation = (name, value) => { const {addError} = this; if (!value.length) { @@ -74,18 +67,18 @@ class ChangeUsernameContainer extends Component { // Removes Error this.setState(state => ({...state, errors})); } - } + }; - isCompleted() { + isCompleted = () => { const {formData} = this.state; return !Object.keys(formData).filter(prop => !formData[prop].length).length; - } + }; - displayErrors(show = true) { + displayErrors = (show = true) => { this.setState({showErrors: show}); - } + }; - handleSubmitUsername(e) { + handleSubmitUsername = e => { e.preventDefault(); const {errors} = this.state; const {validForm, invalidForm} = this.props; @@ -96,11 +89,11 @@ class ChangeUsernameContainer extends Component { } else { invalidForm(lang.t('createdisplay.checkTheForm')); } - } + }; - handleClose() { + handleClose = () => { this.props.hideCreateUsernameDialog(); - } + }; render() { const {loggedIn, auth} = this.props; @@ -122,14 +115,17 @@ class ChangeUsernameContainer extends Component { const mapStateToProps = ({auth, user}) => ({auth, user}); -const mapDispatchToProps = dispatch => ({ - createUsername: (userid, formData) => - dispatch(createUsername(userid, formData)), - showCreateUsernameDialog: () => dispatch(showCreateUsernameDialog()), - hideCreateUsernameDialog: () => dispatch(hideCreateUsernameDialog()), - invalidForm: error => dispatch(invalidForm(error)), - validForm: () => dispatch(validForm()) -}); +const mapDispatchToProps = dispatch => + bindActionCreators( + { + createUsername, + showCreateUsernameDialog, + hideCreateUsernameDialog, + invalidForm, + validForm + }, + dispatch + ); export default connect(mapStateToProps, mapDispatchToProps)( ChangeUsernameContainer diff --git a/plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js b/plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js index b94b47c42..c352552ae 100644 --- a/plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js +++ b/plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js @@ -1,21 +1,26 @@ import React from 'react'; -import TextField from 'coral-ui/components/TextField'; -import Button from 'coral-ui/components/Button'; -import {Dialog, Alert} from 'coral-ui'; -import FakeComment from './FakeComment'; - import styles from './styles.css'; - -import I18n from 'coral-framework/modules/i18n/i18n'; +import {Dialog, Alert, TextField} from 'coral-ui'; +import {FakeComment} from './FakeComment'; import translations from '../translations'; +import Button from 'coral-ui/components/Button'; +import I18n from 'coral-framework/modules/i18n/i18n'; + const lang = new I18n(translations); -const CreateUsernameDialog = ({open, handleClose, formData, handleSubmitUsername, handleChange, ...props}) => { - return ( +const CreateUsernameDialog = ({ + open, + handleClose, + formData, + handleSubmitUsername, + handleChange, + ...props +}) => ( + open={open} + > ×
@@ -24,17 +29,24 @@ const CreateUsernameDialog = ({open, handleClose, formData, handleSubmitUsername
-

{lang.t('createdisplay.yourusername')}

+

+ {lang.t('createdisplay.yourusername')} +

-

{lang.t('createdisplay.ifyoudontchangeyourname')}

- { props.auth.error && {props.auth.error} } +

+ {lang.t('createdisplay.ifyoudontchangeyourname')} +

+ {props.auth.error && {props.auth.error}}
- { props.errors.username && {lang.t('createdisplay.specialCharacters')} } + {props.errors.username && + + {' '}{lang.t('createdisplay.specialCharacters')}{' '} + }
- +
-
+
- ); -}; +); export default CreateUsernameDialog; diff --git a/plugins/coral-plugin-auth/client/components/FakeComment.js b/plugins/coral-plugin-auth/client/components/FakeComment.js index 37630383d..01cc6863e 100644 --- a/plugins/coral-plugin-auth/client/components/FakeComment.js +++ b/plugins/coral-plugin-auth/client/components/FakeComment.js @@ -1,66 +1,72 @@ import React from 'react'; -import styles from 'coral-embed-stream/src/components/Comment.css'; - +import translations from '../translations'; +import {ReplyButton} from 'coral-plugin-replies'; +import PubDate from 'coral-plugin-pubdate/PubDate'; +import I18n from 'coral-framework/modules/i18n/i18n'; import AuthorName from 'coral-plugin-author-name/AuthorName'; import Content from 'coral-plugin-commentcontent/CommentContent'; -import PubDate from 'coral-plugin-pubdate/PubDate'; -import {ReplyButton} from 'coral-plugin-replies'; - -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; +import styles from 'coral-embed-stream/src/components/Comment.css'; const lang = new I18n(translations); -class FakeComment extends React.Component { - constructor (props) { - super(props); - } - - render () { - const {username, created_at, body} = this.props; - - return ( -
-
- - - -
-
- -
- {}} - parentCommentId={'commentID'} - currentUserId={{}} - banned={false} - /> -
-
-
- -
-
- -
-
+export const FakeComment = ({username, created_at, body}) => ( +
+
+ + + +
+
+
- ); - } -} - -export default FakeComment; + {}} + parentCommentId={'commentID'} + currentUserId={{}} + banned={false} + /> +
+
+
+ +
+
+ +
+
+
+); \ No newline at end of file diff --git a/plugins/coral-plugin-auth/client/components/ForgotContent.js b/plugins/coral-plugin-auth/client/components/ForgotContent.js index 76246fa00..2099330bc 100644 --- a/plugins/coral-plugin-auth/client/components/ForgotContent.js +++ b/plugins/coral-plugin-auth/client/components/ForgotContent.js @@ -1,22 +1,18 @@ import React from 'react'; import styles from './styles.css'; +import translations from '../translations'; import Button from 'coral-ui/components/Button'; import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; + const lang = new I18n(translations); class ForgotContent extends React.Component { - constructor (props) { - super(props); - this.handleSubmit = this.handleSubmit.bind(this); - } - - handleSubmit (e) { + handleSubmit = e => { e.preventDefault(); this.props.fetchForgotPassword(this.emailInput.value); - } + }; - render () { + render() { const {changeView, auth} = this.props; const {passwordRequestSuccess, passwordRequestFailure} = auth; @@ -29,29 +25,47 @@ class ForgotContent extends React.Component {
this.emailInput = input} + ref={input => (this.emailInput = input)} type="text" style={{fontSize: 16}} id="email" - name="email" /> + name="email" + />
- - { - passwordRequestSuccess - ?

{passwordRequestSuccess}

- : null - } - { - passwordRequestFailure - ?

{passwordRequestFailure}

- : null - } + {passwordRequestSuccess + ?

+ {passwordRequestSuccess} +

+ : null} + {passwordRequestFailure + ?

+ {passwordRequestFailure} +

+ : null}
- {lang.t('signIn.needAnAccount')} changeView('SIGNUP')}>{lang.t('signIn.register')} - {lang.t('signIn.alreadyHaveAnAccount')} changeView('SIGNIN')}>{lang.t('signIn.signIn')} + + {lang.t('signIn.needAnAccount')} + {' '} + changeView('SIGNUP')}> + {lang.t('signIn.register')} + + + + {lang.t('signIn.alreadyHaveAnAccount')} + {' '} + changeView('SIGNIN')}> + {lang.t('signIn.signIn')} + +
); diff --git a/plugins/coral-plugin-auth/client/components/SignDialog.js b/plugins/coral-plugin-auth/client/components/SignDialog.js index ff2464f7c..7f05889a0 100644 --- a/plugins/coral-plugin-auth/client/components/SignDialog.js +++ b/plugins/coral-plugin-auth/client/components/SignDialog.js @@ -6,12 +6,9 @@ import SignInContent from './SignInContent'; import SignUpContent from './SignUpContent'; import ForgotContent from './ForgotContent'; -const SignDialog = ({open, view, handleClose, ...props}) => ( - - × +const SignDialog = ({open, view, hideSignInDialog, ...props}) => ( + + × {view === 'SIGNIN' && } {view === 'SIGNUP' && } {view === 'FORGOT' && } diff --git a/plugins/coral-plugin-auth/client/components/SignInButton.js b/plugins/coral-plugin-auth/client/components/SignInButton.js index b4497bc92..b54cbfedd 100644 --- a/plugins/coral-plugin-auth/client/components/SignInButton.js +++ b/plugins/coral-plugin-auth/client/components/SignInButton.js @@ -6,13 +6,11 @@ import {showSignInDialog} from 'coral-framework/actions/auth'; const SignInButton = ({loggedIn, showSignInDialog}) => (
- { - !loggedIn ? ( - - ) : null - } + : null}
); diff --git a/plugins/coral-plugin-auth/client/components/SignInContainer.js b/plugins/coral-plugin-auth/client/components/SignInContainer.js index 5a8ffa11a..cbff000ee 100644 --- a/plugins/coral-plugin-auth/client/components/SignInContainer.js +++ b/plugins/coral-plugin-auth/client/components/SignInContainer.js @@ -169,18 +169,16 @@ class SignInContainer extends React.Component { const {emailVerificationLoading, emailVerificationSuccess} = auth; return ( -
- -
+ ); } } diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js index 867849cac..41fa3adbe 100644 --- a/plugins/coral-plugin-auth/client/index.js +++ b/plugins/coral-plugin-auth/client/index.js @@ -1,7 +1,7 @@ import UserBox from './components/UserBox'; import SignInButton from './components/SignInButton'; import SignInContainer from './components/SignInContainer'; -import ChangeUserNameContainer from './components/ChangeUserNameContainer'; +import ChangeUserNameContainer from './components/ChangeUsername'; export default { slots: {