From 87ada30eff70bd580ae6fdb6885a682b22563a35 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 19 May 2017 17:32:16 -0300 Subject: [PATCH 01/14] =?UTF-8?q?=C3=81dding=20Stream=20Slot?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/Embed.js | 11 +-- .../src/components/Stream.js | 94 +++++++++---------- 2 files changed, 51 insertions(+), 54 deletions(-) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index 0d26cf740..2e050e836 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -1,13 +1,12 @@ import React from 'react'; -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from 'coral-framework/translations'; const lang = new I18n(translations); - -import {TabBar, Tab, TabContent, Button} from 'coral-ui'; - import Stream from '../containers/Stream'; -import Count from 'coral-plugin-comment-count/CommentCount'; +import Slot from 'coral-framework/components/Slot'; +import I18n from 'coral-framework/modules/i18n/i18n'; import UserBox from 'coral-sign-in/components/UserBox'; +import translations from 'coral-framework/translations'; +import {TabBar, Tab, TabContent, Button} from 'coral-ui'; +import Count from 'coral-plugin-comment-count/CommentCount'; import ProfileContainer from 'coral-settings/containers/ProfileContainer'; import RestrictedContent from 'coral-framework/components/RestrictedContent'; import ConfigureStreamContainer from 'coral-configure/containers/ConfigureStreamContainer'; diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index 90fa0aca8..e0c541341 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -4,6 +4,7 @@ import {Button} from 'coral-ui'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; import Comment from '../containers/Comment'; +import Slot from 'coral-framework/components/Slot'; import InfoBox from 'coral-plugin-infobox/InfoBox'; import {ModerationLink} from 'coral-plugin-moderation'; import CommentBox from 'coral-plugin-commentbox/CommentBox'; @@ -15,7 +16,7 @@ import ChangeUsernameContainer from 'coral-sign-in/containers/ChangeUsernameContainer'; class Stream extends React.Component { - setActiveReplyBox = (reactKey) => { + setActiveReplyBox = reactKey => { if (!this.props.auth.user) { this.props.showSignInDialog(); } else { @@ -58,11 +59,20 @@ class Stream extends React.Component { const firstCommentDate = asset.comments[0] ? asset.comments[0].created_at : new Date(Date.now() - 1000 * 60 * 60 * 24 * 7).toISOString(); - const commentIsIgnored = (comment) => { - return me && me.ignoredUsers && me.ignoredUsers.find((u) => u.id === comment.user.id); + const commentIsIgnored = comment => { + return ( + me && + me.ignoredUsers && + me.ignoredUsers.find(u => u.id === comment.user.id) + ); }; return (
+ + + {open ?
:

{asset.settings.closedMessage}

} - {!loggedIn && - } {loggedIn && user && } {loggedIn && } - {/* the highlightedComment is isolated after the user followed a permalink */} {highlightedComment ?
- {comments.map( - (comment) => { - return (commentIsIgnored(comment) - ? - : - ); - } - )} + {comments.map(comment => { + return commentIsIgnored(comment) + ? + : ; + })}
Date: Fri, 19 May 2017 17:32:54 -0300 Subject: [PATCH 02/14] Adding coral-plugin-auth --- .gitignore | 1 + plugins/coral-plugin-auth/client/.babelrc | 14 +++++++++++ .../coral-plugin-auth/client/.eslintrc.json | 23 +++++++++++++++++++ .../client/components/SignInButton.js | 22 ++++++++++++++++++ plugins/coral-plugin-auth/client/index.js | 7 ++++++ .../client/translations.json | 10 ++++++++ plugins/coral-plugin-auth/index.js | 1 + 7 files changed, 78 insertions(+) create mode 100644 plugins/coral-plugin-auth/client/.babelrc create mode 100644 plugins/coral-plugin-auth/client/.eslintrc.json create mode 100644 plugins/coral-plugin-auth/client/components/SignInButton.js create mode 100644 plugins/coral-plugin-auth/client/index.js create mode 100644 plugins/coral-plugin-auth/client/translations.json create mode 100644 plugins/coral-plugin-auth/index.js diff --git a/.gitignore b/.gitignore index f0c3b2a4b..11e738d57 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ coverage/ plugins.json plugins/* !plugins/coral-plugin-facebook-auth +!plugins/coral-plugin-auth !plugins/coral-plugin-respect !plugins/coral-plugin-offtopic !plugins/coral-plugin-like diff --git a/plugins/coral-plugin-auth/client/.babelrc b/plugins/coral-plugin-auth/client/.babelrc new file mode 100644 index 000000000..60be246eb --- /dev/null +++ b/plugins/coral-plugin-auth/client/.babelrc @@ -0,0 +1,14 @@ +{ + "presets": [ + "es2015" + ], + "plugins": [ + "add-module-exports", + "transform-class-properties", + "transform-decorators-legacy", + "transform-object-assign", + "transform-object-rest-spread", + "transform-async-to-generator", + "transform-react-jsx" + ] +} \ No newline at end of file diff --git a/plugins/coral-plugin-auth/client/.eslintrc.json b/plugins/coral-plugin-auth/client/.eslintrc.json new file mode 100644 index 000000000..9fe56bd14 --- /dev/null +++ b/plugins/coral-plugin-auth/client/.eslintrc.json @@ -0,0 +1,23 @@ +{ + "env": { + "browser": true, + "es6": true, + "mocha": true + }, + "parserOptions": { + "sourceType": "module", + "ecmaFeatures": { + "experimentalObjectRestSpread": true, + "jsx": true + } + }, + "parser": "babel-eslint", + "plugins": [ + "react" + ], + "rules": { + "react/jsx-uses-react": "error", + "react/jsx-uses-vars": "error", + "no-console": ["warn", { "allow": ["warn", "error"] }] + } +} diff --git a/plugins/coral-plugin-auth/client/components/SignInButton.js b/plugins/coral-plugin-auth/client/components/SignInButton.js new file mode 100644 index 000000000..fb58eeb9b --- /dev/null +++ b/plugins/coral-plugin-auth/client/components/SignInButton.js @@ -0,0 +1,22 @@ +import React from 'react'; +import {Button} from 'coral-ui'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import {showSignInDialog} from 'coral-framework/actions/auth'; + +class SignInButton extends React.Component { + render() { + return ( + + ); + } +} + +const mapStateToProps = ({auth}) => ({auth}); + +const mapDispatchToProps = dispatch => + bindActionCreators({showSignInDialog}, dispatch); + +export default connect(mapStateToProps, mapDispatchToProps)(SignInButton); diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js new file mode 100644 index 000000000..ff601992b --- /dev/null +++ b/plugins/coral-plugin-auth/client/index.js @@ -0,0 +1,7 @@ +import SignInButton from './components/SignInButton'; + +export default { + slots: { + stream: [SignInButton] + } +}; \ No newline at end of file diff --git a/plugins/coral-plugin-auth/client/translations.json b/plugins/coral-plugin-auth/client/translations.json new file mode 100644 index 000000000..93d73d3a2 --- /dev/null +++ b/plugins/coral-plugin-auth/client/translations.json @@ -0,0 +1,10 @@ +{ + "en": { + "like": "Like", + "liked": "Liked" + }, + "es": { + "like": "Me Gusta", + "liked": "Me Gustó" + } +} diff --git a/plugins/coral-plugin-auth/index.js b/plugins/coral-plugin-auth/index.js new file mode 100644 index 000000000..a09954537 --- /dev/null +++ b/plugins/coral-plugin-auth/index.js @@ -0,0 +1 @@ +module.exports = {}; \ No newline at end of file From 3af49de0cefc45c43d1226ff2654b87cd0bb6d5f Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 19 May 2017 18:04:54 -0300 Subject: [PATCH 03/14] New login slots and auth plugins --- client/coral-embed-stream/src/AppRouter.js | 6 +- .../containers/LoginContainer.js | 6 + .../containers/SignInContainer.js | 223 +----------------- .../client/components/SignInContainer.js | 210 +++++++++++++++++ plugins/coral-plugin-auth/client/index.js | 4 +- 5 files changed, 226 insertions(+), 223 deletions(-) create mode 100644 client/coral-sign-in/containers/LoginContainer.js create mode 100644 plugins/coral-plugin-auth/client/components/SignInContainer.js diff --git a/client/coral-embed-stream/src/AppRouter.js b/client/coral-embed-stream/src/AppRouter.js index e2553889c..6ee63caab 100644 --- a/client/coral-embed-stream/src/AppRouter.js +++ b/client/coral-embed-stream/src/AppRouter.js @@ -2,12 +2,12 @@ import React from 'react'; import {Router, Route, browserHistory} from 'react-router'; import Embed from './containers/Embed'; -import SignInContainer from 'coral-sign-in/containers/SignInContainer'; +import {LoginContainer} from 'coral-sign-in/containers/LoginContainer'; const routes = (
- - + +
); diff --git a/client/coral-sign-in/containers/LoginContainer.js b/client/coral-sign-in/containers/LoginContainer.js new file mode 100644 index 000000000..fa20de4ed --- /dev/null +++ b/client/coral-sign-in/containers/LoginContainer.js @@ -0,0 +1,6 @@ +import React from 'react'; +import Slot from 'coral-framework/components/Slot'; + +export const LoginContainer = () => ( + +) \ No newline at end of file diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js index de1d2086e..b473626db 100644 --- a/client/coral-sign-in/containers/SignInContainer.js +++ b/client/coral-sign-in/containers/SignInContainer.js @@ -1,220 +1,5 @@ -import React, {Component, PropTypes} from 'react'; -import {connect} from 'react-redux'; -import SignDialog from '../components/SignDialog'; -import validate from 'coral-framework/helpers/validate'; -import errorMsj from 'coral-framework/helpers/error'; -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; -import {pym} from 'coral-framework'; -const lang = new I18n(translations); +import React from 'react'; -import { - changeView, - fetchSignUp, - fetchSignIn, - hideSignInDialog, - fetchSignInFacebook, - fetchSignUpFacebook, - fetchForgotPassword, - requestConfirmEmail, - facebookCallback, - invalidForm, - validForm, - checkLogin -} from 'coral-framework/actions/auth'; - -class SignInContainer extends Component { - initialState = { - formData: { - email: '', - username: '', - password: '', - confirmPassword: '' - }, - emailToBeResent: '', - errors: {}, - showErrors: false - }; - - constructor(props) { - super(props); - this.state = this.initialState; - this.addError = this.addError.bind(this); - this.handleAuth = this.handleAuth.bind(this); - this.handleSignUp = this.handleSignUp.bind(this); - this.handleSignIn = this.handleSignIn.bind(this); - this.handleChange = this.handleChange.bind(this); - this.handleChangeEmail = this.handleChangeEmail.bind(this); - this.handleResendVerification = this.handleResendVerification.bind(this); - } - - static propTypes = { - requireEmailConfirmation: PropTypes.bool.isRequired - }; - - componentWillMount() { - this.props.checkLogin(); - } - - componentDidMount() { - window.addEventListener('storage', this.handleAuth); - - const {formData} = this.state; - const errors = Object.keys(formData).reduce((map, prop) => { - map[prop] = lang.t('signIn.requiredField'); - return map; - }, {}); - this.setState({errors}); - } - - componentWillUnmount() { - window.removeEventListener('storage', this.handleAuth); - } - - handleAuth(e) { - - // Listening to FB changes - // FB localStorage key is 'auth' - const authCallback = this.props.facebookCallback; - - if (e.key === 'auth') { - const {err, data} = JSON.parse(e.newValue); - authCallback(err, data); - } - } - - handleChange(e) { - const {name, value} = e.target; - this.setState( - (state) => ({ - ...state, - formData: { - ...state.formData, - [name]: value - } - }), - () => { - this.validation(name, value); - } - ); - } - - handleChangeEmail(e) { - const {value} = e.target; - this.setState({emailToBeResent: value}); - } - - handleResendVerification(e) { - e.preventDefault(); - this.props - .requestConfirmEmail( - this.state.emailToBeResent, - pym.parentUrl || location.href - ) - .then(() => { - setTimeout(() => { - - // allow success UI to be shown for a second, and then close the modal - this.props.handleClose(); - }, 2500); - }); - } - - addError(name, error) { - return this.setState((state) => ({ - errors: { - ...state.errors, - [name]: error - } - })); - } - - validation(name, value) { - const {addError} = this; - const {formData} = this.state; - - if (!value.length) { - addError(name, lang.t('signIn.requiredField')); - } else if ( - name === 'confirmPassword' && - formData.confirmPassword !== formData.password - ) { - addError('confirmPassword', lang.t('signIn.passwordsDontMatch')); - } else if (!validate[name](value)) { - addError(name, errorMsj[name]); - } else { - const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line - // Removes Error - this.setState((state) => ({...state, errors})); - } - } - - isCompleted() { - const {formData} = this.state; - return !Object.keys(formData).filter((prop) => !formData[prop].length).length; - } - - displayErrors(show = true) { - this.setState({showErrors: show}); - } - - handleSignUp(e) { - e.preventDefault(); - const {errors} = this.state; - const {fetchSignUp, validForm, invalidForm} = this.props; - this.displayErrors(); - if (this.isCompleted() && !Object.keys(errors).length) { - fetchSignUp(this.state.formData, pym.parentUrl || location.href); - validForm(); - } else { - invalidForm(lang.t('signIn.checkTheForm')); - } - } - - handleSignIn(e) { - e.preventDefault(); - this.props.fetchSignIn(this.state.formData); - } - - render() { - const {auth, requireEmailConfirmation} = this.props; - const {emailVerificationLoading, emailVerificationSuccess} = auth; - - return ( -
- -
- ); - } -} - -const mapStateToProps = (state) => ({ - auth: state.auth.toJS() -}); - -const mapDispatchToProps = (dispatch) => ({ - checkLogin: () => dispatch(checkLogin()), - facebookCallback: (err, data) => dispatch(facebookCallback(err, data)), - fetchSignUp: (formData, url) => dispatch(fetchSignUp(formData, url)), - fetchSignIn: (formData) => dispatch(fetchSignIn(formData)), - fetchSignInFacebook: () => dispatch(fetchSignInFacebook()), - fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()), - fetchForgotPassword: (formData) => dispatch(fetchForgotPassword(formData)), - requestConfirmEmail: (email, url) => - dispatch(requestConfirmEmail(email, url)), - changeView: (view) => dispatch(changeView(view)), - handleClose: () => dispatch(hideSignInDialog()), - invalidForm: (error) => dispatch(invalidForm(error)), - validForm: () => dispatch(validForm()) -}); - -export default connect(mapStateToProps, mapDispatchToProps)(SignInContainer); +export const SignInContainer = () => ( + +) \ No newline at end of file diff --git a/plugins/coral-plugin-auth/client/components/SignInContainer.js b/plugins/coral-plugin-auth/client/components/SignInContainer.js new file mode 100644 index 000000000..06a747556 --- /dev/null +++ b/plugins/coral-plugin-auth/client/components/SignInContainer.js @@ -0,0 +1,210 @@ +import React, {Component, PropTypes} from 'react'; +import {connect} from 'react-redux'; +import validate from 'coral-framework/helpers/validate'; +import errorMsj from 'coral-framework/helpers/error'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from '../translations'; +import {pym} from 'coral-framework'; +const lang = new I18n(translations); + +import { + changeView, + fetchSignUp, + fetchSignIn, + hideSignInDialog, + fetchSignInFacebook, + fetchSignUpFacebook, + fetchForgotPassword, + requestConfirmEmail, + facebookCallback, + invalidForm, + validForm, + checkLogin +} from 'coral-framework/actions/auth'; + +class SignInContainer extends Component { + initialState = { + formData: { + email: '', + username: '', + password: '', + confirmPassword: '' + }, + emailToBeResent: '', + errors: {}, + showErrors: false + }; + + constructor(props) { + super(props); + this.state = this.initialState; + this.addError = this.addError.bind(this); + this.handleAuth = this.handleAuth.bind(this); + this.handleSignUp = this.handleSignUp.bind(this); + this.handleSignIn = this.handleSignIn.bind(this); + this.handleChange = this.handleChange.bind(this); + this.handleChangeEmail = this.handleChangeEmail.bind(this); + this.handleResendVerification = this.handleResendVerification.bind(this); + } + + static propTypes = { + requireEmailConfirmation: PropTypes.bool.isRequired + }; + + componentWillMount() { + this.props.checkLogin(); + } + + componentDidMount() { + window.addEventListener('storage', this.handleAuth); + + const {formData} = this.state; + const errors = Object.keys(formData).reduce((map, prop) => { + map[prop] = lang.t('signIn.requiredField'); + return map; + }, {}); + this.setState({errors}); + } + + componentWillUnmount() { + window.removeEventListener('storage', this.handleAuth); + } + + handleAuth(e) { + + // Listening to FB changes + // FB localStorage key is 'auth' + const authCallback = this.props.facebookCallback; + + if (e.key === 'auth') { + const {err, data} = JSON.parse(e.newValue); + authCallback(err, data); + } + } + + handleChange(e) { + const {name, value} = e.target; + this.setState( + (state) => ({ + ...state, + formData: { + ...state.formData, + [name]: value + } + }), + () => { + this.validation(name, value); + } + ); + } + + handleChangeEmail(e) { + const {value} = e.target; + this.setState({emailToBeResent: value}); + } + + handleResendVerification(e) { + e.preventDefault(); + this.props + .requestConfirmEmail( + this.state.emailToBeResent, + pym.parentUrl || location.href + ) + .then(() => { + setTimeout(() => { + + // allow success UI to be shown for a second, and then close the modal + this.props.handleClose(); + }, 2500); + }); + } + + addError(name, error) { + return this.setState((state) => ({ + errors: { + ...state.errors, + [name]: error + } + })); + } + + validation(name, value) { + const {addError} = this; + const {formData} = this.state; + + if (!value.length) { + addError(name, lang.t('signIn.requiredField')); + } else if ( + name === 'confirmPassword' && + formData.confirmPassword !== formData.password + ) { + addError('confirmPassword', lang.t('signIn.passwordsDontMatch')); + } else if (!validate[name](value)) { + addError(name, errorMsj[name]); + } else { + const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line + // Removes Error + this.setState((state) => ({...state, errors})); + } + } + + isCompleted() { + const {formData} = this.state; + return !Object.keys(formData).filter((prop) => !formData[prop].length).length; + } + + displayErrors(show = true) { + this.setState({showErrors: show}); + } + + handleSignUp(e) { + e.preventDefault(); + const {errors} = this.state; + const {fetchSignUp, validForm, invalidForm} = this.props; + this.displayErrors(); + if (this.isCompleted() && !Object.keys(errors).length) { + fetchSignUp(this.state.formData, pym.parentUrl || location.href); + validForm(); + } else { + invalidForm(lang.t('signIn.checkTheForm')); + } + } + + handleSignIn(e) { + e.preventDefault(); + this.props.fetchSignIn(this.state.formData); + } + + render() { + const {auth, requireEmailConfirmation} = this.props; + const {emailVerificationLoading, emailVerificationSuccess} = auth; + + return ( +
+ This is my login +
+ ); + } +} + +const mapStateToProps = (state) => ({ + auth: state.auth.toJS() +}); + +const mapDispatchToProps = (dispatch) => ({ + checkLogin: () => dispatch(checkLogin()), + facebookCallback: (err, data) => dispatch(facebookCallback(err, data)), + fetchSignUp: (formData, url) => dispatch(fetchSignUp(formData, url)), + fetchSignIn: (formData) => dispatch(fetchSignIn(formData)), + fetchSignInFacebook: () => dispatch(fetchSignInFacebook()), + fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()), + fetchForgotPassword: (formData) => dispatch(fetchForgotPassword(formData)), + requestConfirmEmail: (email, url) => + dispatch(requestConfirmEmail(email, url)), + changeView: (view) => dispatch(changeView(view)), + handleClose: () => dispatch(hideSignInDialog()), + invalidForm: (error) => dispatch(invalidForm(error)), + validForm: () => dispatch(validForm()) +}); + +export default connect(mapStateToProps, mapDispatchToProps)(SignInContainer); diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js index ff601992b..8d2eecc3c 100644 --- a/plugins/coral-plugin-auth/client/index.js +++ b/plugins/coral-plugin-auth/client/index.js @@ -1,7 +1,9 @@ import SignInButton from './components/SignInButton'; +import SignInContainer from './components/SignInContainer'; export default { slots: { - stream: [SignInButton] + stream: [SignInButton], + login: [SignInContainer] } }; \ No newline at end of file From dbfd2aff7cdc2a8987f7740586d1d689ba4f6e48 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 19 May 2017 19:29:50 -0300 Subject: [PATCH 04/14] SignInButton --- .../src/components/Embed.js | 1 - .../src/components/Stream.js | 10 ++++----- .../containers/LoginContainer.js | 2 +- .../containers/SignInContainer.js | 2 +- .../client/components/SignInButton.js | 22 ++++++++++--------- 5 files changed, 18 insertions(+), 19 deletions(-) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index 2e050e836..3a898295f 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -1,7 +1,6 @@ import React from 'react'; const lang = new I18n(translations); import Stream from '../containers/Stream'; -import Slot from 'coral-framework/components/Slot'; import I18n from 'coral-framework/modules/i18n/i18n'; import UserBox from 'coral-sign-in/components/UserBox'; import translations from 'coral-framework/translations'; diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index e0c541341..60747e1a2 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -1,6 +1,4 @@ import React, {PropTypes} from 'react'; - -import {Button} from 'coral-ui'; import LoadMore from './LoadMore'; import NewCount from './NewCount'; import Comment from '../containers/Comment'; @@ -16,7 +14,7 @@ import ChangeUsernameContainer from 'coral-sign-in/containers/ChangeUsernameContainer'; class Stream extends React.Component { - setActiveReplyBox = reactKey => { + setActiveReplyBox = (reactKey) => { if (!this.props.auth.user) { this.props.showSignInDialog(); } else { @@ -59,11 +57,11 @@ class Stream extends React.Component { const firstCommentDate = asset.comments[0] ? asset.comments[0].created_at : new Date(Date.now() - 1000 * 60 * 60 * 24 * 7).toISOString(); - const commentIsIgnored = comment => { + const commentIsIgnored = (comment) => { return ( me && me.ignoredUsers && - me.ignoredUsers.find(u => u.id === comment.user.id) + me.ignoredUsers.find((u) => u.id === comment.user.id) ); }; return ( @@ -151,7 +149,7 @@ class Stream extends React.Component { setCommentCountCache={this.props.setCommentCountCache} />
- {comments.map(comment => { + {comments.map((comment) => { return commentIsIgnored(comment) ? : ( -) \ No newline at end of file +); diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js index b473626db..4e883c765 100644 --- a/client/coral-sign-in/containers/SignInContainer.js +++ b/client/coral-sign-in/containers/SignInContainer.js @@ -2,4 +2,4 @@ import React from 'react'; export const SignInContainer = () => ( -) \ No newline at end of file +); diff --git a/plugins/coral-plugin-auth/client/components/SignInButton.js b/plugins/coral-plugin-auth/client/components/SignInButton.js index fb58eeb9b..b5a88431f 100644 --- a/plugins/coral-plugin-auth/client/components/SignInButton.js +++ b/plugins/coral-plugin-auth/client/components/SignInButton.js @@ -4,17 +4,19 @@ import {connect} from 'react-redux'; import {bindActionCreators} from 'redux'; import {showSignInDialog} from 'coral-framework/actions/auth'; -class SignInButton extends React.Component { - render() { - return ( - - ); - } -} +const SignInButton = ({loggedIn, showSignInDialog}) => ( +
+ { + !loggedIn ? ( + + ) : null + } +
+); -const mapStateToProps = ({auth}) => ({auth}); +const mapStateToProps = ({auth}) => ({loggedIn: auth.loggedIn}); const mapDispatchToProps = dispatch => bindActionCreators({showSignInDialog}, dispatch); From 801a6f8a534f23b59968d8e64c152ccb3db9dad3 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 19 May 2017 20:00:33 -0300 Subject: [PATCH 05/14] External plugin auth fully working, now refactor --- .../src/components/Embed.js | 10 +- .../src/components/Stream.js | 5 - client/coral-sign-in/components/UserBox.js | 15 --- .../containers/SignInContainer.js | 5 - .../components}/ChangeUsernameContainer.js | 51 ++++----- .../components/CreateUsernameDialog.js | 0 .../client}/components/FakeComment.js | 0 .../client}/components/ForgotContent.js | 0 .../client}/components/SignDialog.js | 0 .../client/components/SignInButton.js | 4 +- .../client/components/SignInContainer.js | 12 ++- .../client}/components/SignInContent.js | 0 .../client}/components/SignUpContent.js | 0 .../client/components/UserBox.js | 34 ++++++ .../client}/components/styles.css | 0 plugins/coral-plugin-auth/client/index.js | 4 +- .../client/translations.json | 100 +++++++++++++++++- 17 files changed, 177 insertions(+), 63 deletions(-) delete mode 100644 client/coral-sign-in/components/UserBox.js delete mode 100644 client/coral-sign-in/containers/SignInContainer.js rename {client/coral-sign-in/containers => plugins/coral-plugin-auth/client/components}/ChangeUsernameContainer.js (73%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/CreateUsernameDialog.js (100%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/FakeComment.js (100%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/ForgotContent.js (100%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/SignDialog.js (100%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/SignInContent.js (100%) rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/SignUpContent.js (100%) create mode 100644 plugins/coral-plugin-auth/client/components/UserBox.js rename {client/coral-sign-in => plugins/coral-plugin-auth/client}/components/styles.css (100%) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index 3a898295f..e6ae3f367 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -1,8 +1,8 @@ import React from 'react'; const lang = new I18n(translations); import Stream from '../containers/Stream'; +import Slot from 'coral-framework/components/Slot'; import I18n from 'coral-framework/modules/i18n/i18n'; -import UserBox from 'coral-sign-in/components/UserBox'; import translations from 'coral-framework/translations'; import {TabBar, Tab, TabContent, Button} from 'coral-ui'; import Count from 'coral-plugin-comment-count/CommentCount'; @@ -34,12 +34,10 @@ export default class Embed extends React.Component { handleShowProfile = () => this.props.setActiveTab('profile'); render () { - const {activeTab, logout, viewAllComments, commentId} = this.props; + const {activeTab, viewAllComments, commentId} = this.props; const {asset: {totalCommentCount}} = this.props.root; const {loggedIn, isAdmin, user} = this.props.auth; - const userBox = ; - return (
@@ -48,6 +46,7 @@ export default class Embed extends React.Component { {lang.t('myProfile')} Configure Stream + { commentId &&
:

{asset.settings.closedMessage}

} - {loggedIn && - user && - } {loggedIn && } {highlightedComment diff --git a/client/coral-sign-in/components/UserBox.js b/client/coral-sign-in/components/UserBox.js deleted file mode 100644 index a44c3d4fb..000000000 --- a/client/coral-sign-in/components/UserBox.js +++ /dev/null @@ -1,15 +0,0 @@ -import React from 'react'; -import styles from './styles.css'; -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; -const lang = new I18n(translations); - -const UserBox = ({className, user, onLogout, onShowProfile}) => ( -
- {lang.t('signIn.loggedInAs')} - {user.username}. {lang.t('signIn.notYou')} - {lang.t('signIn.logout')} -
-); - -export default UserBox; diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js deleted file mode 100644 index 4e883c765..000000000 --- a/client/coral-sign-in/containers/SignInContainer.js +++ /dev/null @@ -1,5 +0,0 @@ -import React from 'react'; - -export const SignInContainer = () => ( - -); diff --git a/client/coral-sign-in/containers/ChangeUsernameContainer.js b/plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js similarity index 73% rename from client/coral-sign-in/containers/ChangeUsernameContainer.js rename to plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js index 12a9a75b8..4f0ad9895 100644 --- a/client/coral-sign-in/containers/ChangeUsernameContainer.js +++ b/plugins/coral-plugin-auth/client/components/ChangeUsernameContainer.js @@ -4,7 +4,7 @@ import {connect} from 'react-redux'; import validate from 'coral-framework/helpers/validate'; import errorMsj from 'coral-framework/helpers/error'; -import CreateUsernameDialog from '../components/CreateUsernameDialog'; +import CreateUsernameDialog from './CreateUsernameDialog'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations'; @@ -16,12 +16,12 @@ import { invalidForm, validForm, createUsername -} from '../../coral-framework/actions/auth'; +} from 'coral-framework/actions/auth'; class ChangeUsernameContainer extends Component { initialState = { formData: { - username: '', + username: '' }, errors: {}, showErrors: false @@ -39,19 +39,22 @@ class ChangeUsernameContainer extends Component { handleChange(e) { const {name, value} = e.target; - this.setState((state) => ({ - ...state, - formData: { - ...state.formData, - [name]: value + this.setState( + state => ({ + ...state, + formData: { + ...state.formData, + [name]: value + } + }), + () => { + this.validation(name, value); } - }), () => { - this.validation(name, value); - }); + ); } addError(name, error) { - return this.setState((state) => ({ + return this.setState(state => ({ errors: { ...state.errors, [name]: error @@ -67,15 +70,15 @@ class ChangeUsernameContainer extends Component { } else if (!validate[name](value)) { addError(name, errorMsj[name]); } else { - const { [name]: prop, ...errors } = this.state.errors; // eslint-disable-line + const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line // Removes Error - this.setState((state) => ({...state, errors})); + this.setState(state => ({...state, errors})); } } isCompleted() { const {formData} = this.state; - return !Object.keys(formData).filter((prop) => !formData[prop].length).length; + return !Object.keys(formData).filter(prop => !formData[prop].length).length; } displayErrors(show = true) { @@ -117,19 +120,17 @@ class ChangeUsernameContainer extends Component { } } -const mapStateToProps = (state) => ({ - auth: state.auth.toJS() -}); +const mapStateToProps = ({auth, user}) => ({auth, user}); -const mapDispatchToProps = (dispatch) => ({ - createUsername: (userid, formData) => dispatch(createUsername(userid, formData)), +const mapDispatchToProps = dispatch => ({ + createUsername: (userid, formData) => + dispatch(createUsername(userid, formData)), showCreateUsernameDialog: () => dispatch(showCreateUsernameDialog()), hideCreateUsernameDialog: () => dispatch(hideCreateUsernameDialog()), - invalidForm: (error) => dispatch(invalidForm(error)), + invalidForm: error => dispatch(invalidForm(error)), validForm: () => dispatch(validForm()) }); -export default connect( - mapStateToProps, - mapDispatchToProps -)(ChangeUsernameContainer); +export default connect(mapStateToProps, mapDispatchToProps)( + ChangeUsernameContainer +); diff --git a/client/coral-sign-in/components/CreateUsernameDialog.js b/plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js similarity index 100% rename from client/coral-sign-in/components/CreateUsernameDialog.js rename to plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js diff --git a/client/coral-sign-in/components/FakeComment.js b/plugins/coral-plugin-auth/client/components/FakeComment.js similarity index 100% rename from client/coral-sign-in/components/FakeComment.js rename to plugins/coral-plugin-auth/client/components/FakeComment.js diff --git a/client/coral-sign-in/components/ForgotContent.js b/plugins/coral-plugin-auth/client/components/ForgotContent.js similarity index 100% rename from client/coral-sign-in/components/ForgotContent.js rename to plugins/coral-plugin-auth/client/components/ForgotContent.js diff --git a/client/coral-sign-in/components/SignDialog.js b/plugins/coral-plugin-auth/client/components/SignDialog.js similarity index 100% rename from client/coral-sign-in/components/SignDialog.js rename to plugins/coral-plugin-auth/client/components/SignDialog.js diff --git a/plugins/coral-plugin-auth/client/components/SignInButton.js b/plugins/coral-plugin-auth/client/components/SignInButton.js index b5a88431f..b4497bc92 100644 --- a/plugins/coral-plugin-auth/client/components/SignInButton.js +++ b/plugins/coral-plugin-auth/client/components/SignInButton.js @@ -16,7 +16,9 @@ const SignInButton = ({loggedIn, showSignInDialog}) => (
); -const mapStateToProps = ({auth}) => ({loggedIn: auth.loggedIn}); +const mapStateToProps = ({auth}) => ({ + loggedIn: auth.toJS().loggedIn +}); const mapDispatchToProps = dispatch => bindActionCreators({showSignInDialog}, dispatch); diff --git a/plugins/coral-plugin-auth/client/components/SignInContainer.js b/plugins/coral-plugin-auth/client/components/SignInContainer.js index 06a747556..73094920e 100644 --- a/plugins/coral-plugin-auth/client/components/SignInContainer.js +++ b/plugins/coral-plugin-auth/client/components/SignInContainer.js @@ -1,5 +1,6 @@ import React, {Component, PropTypes} from 'react'; import {connect} from 'react-redux'; +import SignDialog from './SignDialog'; import validate from 'coral-framework/helpers/validate'; import errorMsj from 'coral-framework/helpers/error'; import I18n from 'coral-framework/modules/i18n/i18n'; @@ -181,7 +182,16 @@ class SignInContainer extends Component { return (
- This is my login +
); } diff --git a/client/coral-sign-in/components/SignInContent.js b/plugins/coral-plugin-auth/client/components/SignInContent.js similarity index 100% rename from client/coral-sign-in/components/SignInContent.js rename to plugins/coral-plugin-auth/client/components/SignInContent.js diff --git a/client/coral-sign-in/components/SignUpContent.js b/plugins/coral-plugin-auth/client/components/SignUpContent.js similarity index 100% rename from client/coral-sign-in/components/SignUpContent.js rename to plugins/coral-plugin-auth/client/components/SignUpContent.js diff --git a/plugins/coral-plugin-auth/client/components/UserBox.js b/plugins/coral-plugin-auth/client/components/UserBox.js new file mode 100644 index 000000000..a4a0e1c99 --- /dev/null +++ b/plugins/coral-plugin-auth/client/components/UserBox.js @@ -0,0 +1,34 @@ +import React from 'react'; +import styles from './styles.css'; +import {connect} from 'react-redux'; +import {bindActionCreators} from 'redux'; +import translations from '../translations'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import {showSignInDialog, logout} from 'coral-framework/actions/auth'; +const lang = new I18n(translations); + +const UserBox = ({loggedIn, user, logout, onShowProfile}) => ( +
+ { + loggedIn ? ( +
+ {lang.t('signIn.loggedInAs')} + {user.username}. {lang.t('signIn.notYou')} + logout()}> + {lang.t('signIn.logout')} + +
+ ) : null + } +
+); + +const mapStateToProps = ({auth, user}) => ({ + loggedIn: auth.toJS().loggedIn, + user: user.toJS() +}); + +const mapDispatchToProps = dispatch => + bindActionCreators({logout}, dispatch); + +export default connect(mapStateToProps, mapDispatchToProps)(UserBox); diff --git a/client/coral-sign-in/components/styles.css b/plugins/coral-plugin-auth/client/components/styles.css similarity index 100% rename from client/coral-sign-in/components/styles.css rename to plugins/coral-plugin-auth/client/components/styles.css diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js index 8d2eecc3c..3bf9e58f0 100644 --- a/plugins/coral-plugin-auth/client/index.js +++ b/plugins/coral-plugin-auth/client/index.js @@ -1,9 +1,11 @@ import SignInButton from './components/SignInButton'; import SignInContainer from './components/SignInContainer'; +import UserBox from './components/UserBox'; +import ChangeUserNameContainer from './components/ChangeUserNameContainer'; export default { slots: { - stream: [SignInButton], + stream: [UserBox, SignInButton, ChangeUserNameContainer], login: [SignInContainer] } }; \ No newline at end of file diff --git a/plugins/coral-plugin-auth/client/translations.json b/plugins/coral-plugin-auth/client/translations.json index 93d73d3a2..7ae84b2ff 100644 --- a/plugins/coral-plugin-auth/client/translations.json +++ b/plugins/coral-plugin-auth/client/translations.json @@ -1,10 +1,102 @@ { "en": { - "like": "Like", - "liked": "Liked" + "signIn": { + "emailVerifyCTA": "Please verify your email address.", + "requestNewVerifyEmail": "Request another email:", + "verifyEmail": "Thank you for creating an account! We sent an email to the address you provided to verify your account.", + "verifyEmail2": "You must verify your account before engaging with the community.", + "notYou": "Not you?", + "loggedInAs": "Logged in as", + "facebookSignIn": "Sign in with Facebook", + "facebookSignUp": "Sign up with Facebook", + "logout": "Logout", + "signIn": "Sign in to join the conversation", + "or": "Or", + "email": "E-mail Address", + "password": "Password", + "forgotYourPass": "Forgot your password?", + "needAnAccount": "Need an account?", + "register": "Register", + "signUp": "Sign Up", + "confirmPassword": "Confirm Password", + "username": "Username", + "alreadyHaveAnAccount": "Already have an account?", + "recoverPassword": "Recover password", + "emailInUse": "Email address already in use", + "emailORusernameInUse": "Email address or Username already in use", + "requiredField": "This field is required", + "passwordsDontMatch": "Passwords don't match.", + "specialCharacters": "Usernames can contain letters, numbers and _ only", + "checkTheForm": "Invalid Form. Please, check the fields" + }, + "createdisplay": { + "writeyourusername": "Edit your username", + "yourusername": "Your username appears on every comment you post.", + "ifyoudontchangeyourname": "If you don't change your username at this step, your Facebook display name will appear alongside of all your comments.", + "username": "Username", + "continue": "Continue with the same Facebook username", + "save": "Save", + "fakecommentdate": "1 minute ago", + "fakecommentbody": "This is an example comment. Readers can share their thoughts and opinions with newsrooms in the comments section.", + "requiredField": "Required field", + "errorCreate": "Error when changing username", + "checkTheForm": "Invalid Form. Please, check the fields", + "specialCharacters": "Usernames can contain letters, numbers and _ only" + }, + "permalink": { + "permalink": "Link" + }, + "report": "Report", + "like": "Like" }, "es": { - "like": "Me Gusta", - "liked": "Me Gustó" + "signIn": { + "emailVerifyCTA": "Por favor verifique su e-mail.", + "requestNewVerifyEmail": "Enviar otro correo:", + "verifyEmail": "¡Gracias por crear una cuenta! Le enviamos un correo a la dirección que dio para verificar su cuenta.", + "verifyEmail2": "Debe verificarla antes de poder involucrarse en la comunidad.", + "notYou": "¿No eres tu?", + "loggedInAs": "Entraste como", + "facebookSignIn": "Entrar con Facebook", + "facebookSignUp": "Regístrate con Facebook", + "logout": "Salir", + "signIn": "Entrar para Unirte a la Conversación", + "or": "o", + "email": "E-mail", + "password": "Contraseña", + "forgotYourPass": "¿Has olvidado tu contraseña?", + "needAnAccount": "¿Necesitas una cuenta?", + "register": "Regístrate", + "signUp": "Registro", + "confirmPassword": "Confirmar Contraseña", + "username": "Nombre", + "alreadyHaveAnAccount": "¿Ya tienes una cuenta?", + "recoverPassword": "Recuperar contraseña", + "emailInUse": "Este e-mail se encuentra en uso", + "emailORusernameInUse": "Este e-mail ó nombre de usuario se encuentran en uso", + "requiredField": "Este campo es requerido", + "passwordsDontMatch": "Las contraseñas no coinciden", + "specialCharacters": "Los nombres pueden contener letras, números y _", + "checkTheForm": "Formulario Inválido. Por favor, completa los campos" + }, + "createdisplay": { + "writeyourusername": "Edita tu nombre", + "yourusername": "Tu nombre aparece en cada comentario que publiques.", + "ifyoudontchangeyourname": "Si no modificas tu nombre de usuario en este paso, tu nombre de Facebook aparecera al lado de cada comentario que publiques.", + "username": "Nombre", + "continue": "Continuar con nombre de Facebook", + "save": "Guardar", + "fakecommentdate": "hace un minuto", + "fakecommentbody": "Este es un comentario de ejemplo. Las lectoras pueden compartir sus ideas y opiniones con los periodistas en la sección de comentarios.", + "requiredField": "Campo necesario", + "errorCreate": "Hubo un error al cambiar el nombre de usuario", + "checkTheForm": "Formulario Inválido. Por favor, verifica los campos", + "specialCharacters": "Sólo pueden contener letras, números y _" + }, + "permalink": { + "permalink": "Enlace" + }, + "report": "Marcar", + "like": "Me gusta" } } From 1aacb565d4d90b8b1a6562266ba0185e987ec20c Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Fri, 19 May 2017 20:10:49 -0300 Subject: [PATCH 06/14] linting --- client/coral-embed-stream/src/components/Embed.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/coral-embed-stream/src/components/Embed.js b/client/coral-embed-stream/src/components/Embed.js index e6ae3f367..2c22cc8a0 100644 --- a/client/coral-embed-stream/src/components/Embed.js +++ b/client/coral-embed-stream/src/components/Embed.js @@ -36,7 +36,7 @@ export default class Embed extends React.Component { render () { const {activeTab, viewAllComments, commentId} = this.props; const {asset: {totalCommentCount}} = this.props.root; - const {loggedIn, isAdmin, user} = this.props.auth; + const {loggedIn, isAdmin} = this.props.auth; return (
From f364a1e0a12015843f35a4884f5bc1822459b6e9 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 22 May 2017 08:23:58 -0300 Subject: [PATCH 07/14] Refactor --- .../client/components/SignInContainer.js | 140 +++++++++--------- .../client/components/SignInContent.js | 47 +++--- .../client/components/SignUpContent.js | 91 ++++++------ plugins/coral-plugin-auth/client/index.js | 2 +- 4 files changed, 139 insertions(+), 141 deletions(-) diff --git a/plugins/coral-plugin-auth/client/components/SignInContainer.js b/plugins/coral-plugin-auth/client/components/SignInContainer.js index 73094920e..5a8ffa11a 100644 --- a/plugins/coral-plugin-auth/client/components/SignInContainer.js +++ b/plugins/coral-plugin-auth/client/components/SignInContainer.js @@ -1,11 +1,13 @@ -import React, {Component, PropTypes} from 'react'; +import React from 'react'; import {connect} from 'react-redux'; -import SignDialog from './SignDialog'; -import validate from 'coral-framework/helpers/validate'; -import errorMsj from 'coral-framework/helpers/error'; -import I18n from 'coral-framework/modules/i18n/i18n'; -import translations from '../translations'; import {pym} from 'coral-framework'; +import SignDialog from './SignDialog'; +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'; + const lang = new I18n(translations); import { @@ -23,34 +25,22 @@ import { checkLogin } from 'coral-framework/actions/auth'; -class SignInContainer extends Component { - initialState = { - formData: { - email: '', - username: '', - password: '', - confirmPassword: '' - }, - emailToBeResent: '', - errors: {}, - showErrors: false - }; - +class SignInContainer extends React.Component { constructor(props) { super(props); - this.state = this.initialState; - this.addError = this.addError.bind(this); - this.handleAuth = this.handleAuth.bind(this); - this.handleSignUp = this.handleSignUp.bind(this); - this.handleSignIn = this.handleSignIn.bind(this); - this.handleChange = this.handleChange.bind(this); - this.handleChangeEmail = this.handleChangeEmail.bind(this); - this.handleResendVerification = this.handleResendVerification.bind(this); - } - static propTypes = { - requireEmailConfirmation: PropTypes.bool.isRequired - }; + this.state = { + formData: { + email: '', + username: '', + password: '', + confirmPassword: '' + }, + emailToBeResent: '', + errors: {}, + showErrors: false + }; + } componentWillMount() { this.props.checkLogin(); @@ -71,8 +61,7 @@ class SignInContainer extends Component { window.removeEventListener('storage', this.handleAuth); } - handleAuth(e) { - + handleAuth = e => { // Listening to FB changes // FB localStorage key is 'auth' const authCallback = this.props.facebookCallback; @@ -81,12 +70,12 @@ class SignInContainer extends Component { const {err, data} = JSON.parse(e.newValue); authCallback(err, data); } - } + }; - handleChange(e) { + handleChange = e => { const {name, value} = e.target; this.setState( - (state) => ({ + state => ({ ...state, formData: { ...state.formData, @@ -97,14 +86,14 @@ class SignInContainer extends Component { this.validation(name, value); } ); - } + }; - handleChangeEmail(e) { + handleChangeEmail = e => { const {value} = e.target; this.setState({emailToBeResent: value}); - } + }; - handleResendVerification(e) { + handleResendVerification = e => { e.preventDefault(); this.props .requestConfirmEmail( @@ -113,23 +102,22 @@ class SignInContainer extends Component { ) .then(() => { setTimeout(() => { - // allow success UI to be shown for a second, and then close the modal - this.props.handleClose(); + this.props.hideSignInDialog(); }, 2500); }); - } + }; - addError(name, error) { - return this.setState((state) => ({ + addError = (name, error) => { + return this.setState(state => ({ errors: { ...state.errors, [name]: error } })); - } + }; - validation(name, value) { + validation = (name, value) => { const {addError} = this; const {formData} = this.state; @@ -145,20 +133,20 @@ class SignInContainer extends Component { } else { const {[name]: prop, ...errors} = this.state.errors; // eslint-disable-line // Removes Error - this.setState((state) => ({...state, errors})); + this.setState(state => ({...state, errors})); } - } + }; - isCompleted() { + isCompleted = () => { const {formData} = this.state; - return !Object.keys(formData).filter((prop) => !formData[prop].length).length; - } + return !Object.keys(formData).filter(prop => !formData[prop].length).length; + }; - displayErrors(show = true) { + displayErrors = (show = true) => { this.setState({showErrors: show}); - } + }; - handleSignUp(e) { + handleSignUp = e => { e.preventDefault(); const {errors} = this.state; const {fetchSignUp, validForm, invalidForm} = this.props; @@ -169,12 +157,12 @@ class SignInContainer extends Component { } else { invalidForm(lang.t('signIn.checkTheForm')); } - } + }; - handleSignIn(e) { + handleSignIn = e => { e.preventDefault(); this.props.fetchSignIn(this.state.formData); - } + }; render() { const {auth, requireEmailConfirmation} = this.props; @@ -197,24 +185,28 @@ class SignInContainer extends Component { } } -const mapStateToProps = (state) => ({ +const mapStateToProps = state => ({ auth: state.auth.toJS() }); -const mapDispatchToProps = (dispatch) => ({ - checkLogin: () => dispatch(checkLogin()), - facebookCallback: (err, data) => dispatch(facebookCallback(err, data)), - fetchSignUp: (formData, url) => dispatch(fetchSignUp(formData, url)), - fetchSignIn: (formData) => dispatch(fetchSignIn(formData)), - fetchSignInFacebook: () => dispatch(fetchSignInFacebook()), - fetchSignUpFacebook: () => dispatch(fetchSignUpFacebook()), - fetchForgotPassword: (formData) => dispatch(fetchForgotPassword(formData)), - requestConfirmEmail: (email, url) => - dispatch(requestConfirmEmail(email, url)), - changeView: (view) => dispatch(changeView(view)), - handleClose: () => dispatch(hideSignInDialog()), - invalidForm: (error) => dispatch(invalidForm(error)), - validForm: () => dispatch(validForm()) -}); +const mapDispatchToProps = dispatch => + bindActionCreators( + { + checkLogin, + facebookCallback, + fetchSignUp, + fetchSignUp, + fetchSignIn, + fetchSignInFacebook, + fetchSignUpFacebook, + fetchForgotPassword, + requestConfirmEmail, + changeView, + hideSignInDialog, + invalidForm, + validForm + }, + dispatch + ); export default connect(mapStateToProps, mapDispatchToProps)(SignInContainer); diff --git a/plugins/coral-plugin-auth/client/components/SignInContent.js b/plugins/coral-plugin-auth/client/components/SignInContent.js index 7460efb97..6f0027084 100644 --- a/plugins/coral-plugin-auth/client/components/SignInContent.js +++ b/plugins/coral-plugin-auth/client/components/SignInContent.js @@ -18,17 +18,17 @@ const SignInContent = ({ auth, fetchSignInFacebook }) => { - return (

- {auth.emailVerificationFailure ? lang.t('signIn.emailVerifyCTA') : lang.t('signIn.signIn')} + {auth.emailVerificationFailure + ? lang.t('signIn.emailVerifyCTA') + : lang.t('signIn.signIn')}

- { auth.error && {auth.error} } - { - auth.emailVerificationFailure + {auth.error && {auth.error}} + {auth.emailVerificationFailure ?

{lang.t('signIn.requestNewVerifyEmail')}

- + onChange={handleChangeEmail} + /> + {emailVerificationLoading && } {emailVerificationSuccess && } @@ -70,23 +73,29 @@ const SignInContent = ({ onChange={handleChange} />
- { - !auth.isLoading ? - - : - - } + {!auth.isLoading + ? + : }
-
- } +
}
- changeView('FORGOT')}>{lang.t('signIn.forgotYourPass')} + + changeView('FORGOT')}> + {lang.t('signIn.forgotYourPass')} + + {lang.t('signIn.needAnAccount')} - changeView('SIGNUP')} id='coralRegister'> + changeView('SIGNUP')} id="coralRegister"> {lang.t('signIn.register')} diff --git a/plugins/coral-plugin-auth/client/components/SignUpContent.js b/plugins/coral-plugin-auth/client/components/SignUpContent.js index 921f045be..5f2dd36ea 100644 --- a/plugins/coral-plugin-auth/client/components/SignUpContent.js +++ b/plugins/coral-plugin-auth/client/components/SignUpContent.js @@ -1,39 +1,21 @@ -import React, {PropTypes} from 'react'; -import {Button, TextField, Spinner, Success, Alert} from 'coral-ui'; import styles from './styles.css'; -import I18n from 'coral-framework/modules/i18n/i18n'; +import React, {PropTypes} from 'react'; import translations from '../translations'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import {Button, TextField, Spinner, Success, Alert} from 'coral-ui'; + const lang = new I18n(translations); class SignUpContent extends React.Component { + constructor() { + super(); - constructor (props) { - super(props); - this.successfulSignup = false; + this.state = { + successfulSignup: false + }; } - static propTypes = { - emailVerificationEnabled: PropTypes.bool.isRequired, - fetchSignUpFacebook: PropTypes.func.isRequired, - changeView: PropTypes.func.isRequired, - handleSignUp: PropTypes.func.isRequired, - showErrors: PropTypes.bool, - errors: PropTypes.shape({ - email: PropTypes.string, - username: PropTypes.string, - password: PropTypes.string, - confirmPassword: PropTypes.string, - }), - formData: PropTypes.shape({ - email: PropTypes.string, - username: PropTypes.string, - password: PropTypes.string, - confirmPassword: PropTypes.string - }) - } - - render () { - + render() { const { handleChange, formData, @@ -43,17 +25,20 @@ class SignUpContent extends React.Component { showErrors, changeView, handleSignUp, - fetchSignUpFacebook} = this.props; + fetchSignUpFacebook + } = this.props; const beforeSignup = !auth.isLoading && !auth.successSignUp; const successfulSignup = !auth.isLoading && auth.successSignUp; // the first time we render a successfulSignup, trigger a timer - if ((this.successfulSignup ^ successfulSignup) && !emailVerificationEnabled) { + if (this.successfulSignup ^ successfulSignup && !emailVerificationEnabled) { setTimeout(() => { changeView('SIGNIN'); }, 1000); - this.successfulSignup = true; + this.setState({ + successfulSignup: true + }); } return ( @@ -64,8 +49,8 @@ class SignUpContent extends React.Component {
- { auth.error && {auth.error} } - { beforeSignup && + {auth.error && {auth.error}} + {beforeSignup &&
- { auth.isLoading && } + {auth.isLoading && }
-
- } - { - successfulSignup && +
} + {successfulSignup &&
- { - emailVerificationEnabled && -

{lang.t('signIn.verifyEmail')}

{lang.t('signIn.verifyEmail2')}

- } -
- } + {emailVerificationEnabled && +

+ {lang.t('signIn.verifyEmail')} +
+
+ {lang.t('signIn.verifyEmail2')} +

} +
}
- {lang.t('signIn.alreadyHaveAnAccount')} changeView('SIGNIN')}> + {lang.t('signIn.alreadyHaveAnAccount')} changeView('SIGNIN')} + > {lang.t('signIn.signIn')}
diff --git a/plugins/coral-plugin-auth/client/index.js b/plugins/coral-plugin-auth/client/index.js index 3bf9e58f0..867849cac 100644 --- a/plugins/coral-plugin-auth/client/index.js +++ b/plugins/coral-plugin-auth/client/index.js @@ -1,6 +1,6 @@ +import UserBox from './components/UserBox'; import SignInButton from './components/SignInButton'; import SignInContainer from './components/SignInContainer'; -import UserBox from './components/UserBox'; import ChangeUserNameContainer from './components/ChangeUserNameContainer'; export default { From 9d00a27f1de3b5c0a170c885c9adb5b19bba47a6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 22 May 2017 08:40:45 -0300 Subject: [PATCH 08/14] Auth as a plugin --- ...UsernameContainer.js => ChangeUsername.js} | 82 ++++++------ .../client/components/CreateUsernameDialog.js | 49 ++++--- .../client/components/FakeComment.js | 124 +++++++++--------- .../client/components/ForgotContent.js | 62 +++++---- .../client/components/SignDialog.js | 9 +- .../client/components/SignInButton.js | 8 +- .../client/components/SignInContainer.js | 22 ++-- plugins/coral-plugin-auth/client/index.js | 2 +- 8 files changed, 190 insertions(+), 168 deletions(-) rename plugins/coral-plugin-auth/client/components/{ChangeUsernameContainer.js => ChangeUsername.js} (69%) 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: { From 9936b6ec47c6e1ec4c3e9a8fb95c8263ff3a12a0 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 22 May 2017 08:59:34 -0300 Subject: [PATCH 09/14] Prettier --- .../src/components/Stream.js | 141 +++++++++--------- 1 file changed, 74 insertions(+), 67 deletions(-) diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index a82d7e639..bdf00c46c 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -19,7 +19,7 @@ import ChangeUsernameContainer const lang = new I18n(translations); class Stream extends React.Component { - setActiveReplyBox = (reactKey) => { + setActiveReplyBox = reactKey => { if (!this.props.auth.user) { this.props.showSignInDialog(); } else { @@ -53,7 +53,10 @@ class Stream extends React.Component { : comment; const banned = user && user.status === 'BANNED'; - const temporarilySuspended = user && user.suspension.until && new Date(user.suspension.until) > new Date(); + const temporarilySuspended = + user && + user.suspension.until && + new Date(user.suspension.until) > new Date(); const hasOlderComments = !!(asset && asset.lastComment && @@ -63,8 +66,12 @@ class Stream extends React.Component { const firstCommentDate = asset.comments[0] ? asset.comments[0].created_at : new Date(Date.now() - 1000 * 60 * 60 * 24 * 7).toISOString(); - const commentIsIgnored = (comment) => { - return me && me.ignoredUsers && me.ignoredUsers.find((u) => u.id === comment.user.id); + const commentIsIgnored = comment => { + return ( + me && + me.ignoredUsers && + me.ignoredUsers.find(u => u.id === comment.user.id) + ); }; return (
@@ -81,38 +88,37 @@ class Stream extends React.Component { content={asset.settings.questionBoxContent} enable={asset.settings.questionBoxEnable} /> - {!banned && temporarilySuspended && + {!banned && + temporarilySuspended && - { - lang.t('temporarilySuspended', - this.props.root.settings.organizationName, - lang.timeago(user.suspension.until), - ) - } - - } + {lang.t( + 'temporarilySuspended', + this.props.root.settings.organizationName, + lang.timeago(user.suspension.until) + )} + } {banned && - } - {loggedIn && !banned && !temporarilySuspended && + />} + {loggedIn && + !banned && + !temporarilySuspended && - } + addNotification={this.props.addNotification} + postComment={this.props.postComment} + appendItemArray={this.props.appendItemArray} + updateItem={this.props.updateItem} + setCommentCountCache={this.props.setCommentCountCache} + commentCountCache={commentCountCache} + assetId={asset.id} + premod={asset.settings.moderation} + isReply={false} + authorId={user.id} + charCountEnable={asset.settings.charCountEnable} + maxCharCount={asset.settings.charCount} + />}
:

{asset.settings.closedMessage}

} {!loggedIn && @@ -126,7 +132,11 @@ class Stream extends React.Component { {loggedIn && user && } - {loggedIn && } + {loggedIn && + } {/* the highlightedComment is isolated after the user followed a permalink */} {highlightedComment @@ -164,41 +174,38 @@ class Stream extends React.Component { setCommentCountCache={this.props.setCommentCountCache} />
- {comments.map( - (comment) => { - return (commentIsIgnored(comment) - ? - : - ); - } - )} + {comments.map(comment => { + return commentIsIgnored(comment) + ? + : ; + })}
Date: Mon, 22 May 2017 09:03:10 -0300 Subject: [PATCH 10/14] linting --- client/coral-embed-stream/src/components/Stream.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index bdf00c46c..ab551e33e 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -19,7 +19,7 @@ import ChangeUsernameContainer const lang = new I18n(translations); class Stream extends React.Component { - setActiveReplyBox = reactKey => { + setActiveReplyBox = (reactKey) => { if (!this.props.auth.user) { this.props.showSignInDialog(); } else { @@ -66,11 +66,11 @@ class Stream extends React.Component { const firstCommentDate = asset.comments[0] ? asset.comments[0].created_at : new Date(Date.now() - 1000 * 60 * 60 * 24 * 7).toISOString(); - const commentIsIgnored = comment => { + const commentIsIgnored = (comment) => { return ( me && me.ignoredUsers && - me.ignoredUsers.find(u => u.id === comment.user.id) + me.ignoredUsers.find((u) => u.id === comment.user.id) ); }; return ( @@ -174,7 +174,7 @@ class Stream extends React.Component { setCommentCountCache={this.props.setCommentCountCache} />
- {comments.map(comment => { + {comments.map((comment) => { return commentIsIgnored(comment) ? : Date: Mon, 22 May 2017 09:39:04 -0300 Subject: [PATCH 11/14] Merge Conflicts --- .../coral-embed-stream/src/components/Stream.js | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js index ab551e33e..53f716954 100644 --- a/client/coral-embed-stream/src/components/Stream.js +++ b/client/coral-embed-stream/src/components/Stream.js @@ -13,8 +13,6 @@ import translations from 'coral-framework/translations'; import CommentBox from 'coral-plugin-commentbox/CommentBox'; import QuestionBox from 'coral-plugin-questionbox/QuestionBox'; import IgnoredCommentTombstone from './IgnoredCommentTombstone'; -import ChangeUsernameContainer - from 'coral-sign-in/containers/ChangeUsernameContainer'; const lang = new I18n(translations); @@ -75,9 +73,7 @@ class Stream extends React.Component { }; return (
- - {open ?
}
:

{asset.settings.closedMessage}

} - {!loggedIn && - } - {loggedIn && - user && - } {loggedIn && Date: Thu, 25 May 2017 16:19:19 -0300 Subject: [PATCH 12/14] Password reset and valid locations --- client/coral-admin/src/actions/auth.js | 7 +++++-- services/users.js | 3 +-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js index 29971e294..2eb85c86a 100644 --- a/client/coral-admin/src/actions/auth.js +++ b/client/coral-admin/src/actions/auth.js @@ -1,6 +1,7 @@ +import {pym} from 'coral-framework'; import * as actions from '../constants/auth'; -import * as Storage from 'coral-framework/helpers/storage'; import coralApi from 'coral-framework/helpers/response'; +import * as Storage from 'coral-framework/helpers/storage'; import {handleAuthToken} from 'coral-framework/actions/auth'; //============================================================================== @@ -52,7 +53,9 @@ const forgotPassowordFailure = () => ({ export const requestPasswordReset = (email) => (dispatch) => { dispatch(forgotPassowordRequest(email)); - return coralApi('/account/password/reset', {method: 'POST', body: {email}}) + const redirectUri = location.href; + + return coralApi('/account/password/reset', {method: 'POST', body: {email, loc: redirectUri}}) .then(() => dispatch(forgotPassowordSuccess())) .catch((error) => dispatch(forgotPassowordFailure(error))); }; diff --git a/services/users.js b/services/users.js index 496db4528..07a690411 100644 --- a/services/users.js +++ b/services/users.js @@ -566,10 +566,9 @@ module.exports = class UsersService { // endpoint. return; } - let redirectDomain; try { - redirectDomain = url.parse(loc).hostname; + redirectDomain = url.parse(loc).host; } catch (e) { return Promise.reject('redirect location is invalid'); } From 21644bda8a7cf18c84dcd3c54f8eee72efd7b3e6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 25 May 2017 16:24:39 -0300 Subject: [PATCH 13/14] Linting --- client/coral-admin/src/actions/auth.js | 1 - 1 file changed, 1 deletion(-) diff --git a/client/coral-admin/src/actions/auth.js b/client/coral-admin/src/actions/auth.js index 2eb85c86a..d5a1eeea1 100644 --- a/client/coral-admin/src/actions/auth.js +++ b/client/coral-admin/src/actions/auth.js @@ -1,4 +1,3 @@ -import {pym} from 'coral-framework'; import * as actions from '../constants/auth'; import coralApi from 'coral-framework/helpers/response'; import * as Storage from 'coral-framework/helpers/storage'; From a8c361e2f7bdc8fea5105b87e6b46eee09ea31b6 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Thu, 25 May 2017 16:53:12 -0300 Subject: [PATCH 14/14] by hostname --- services/users.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/services/users.js b/services/users.js index 07a690411..4c76f179c 100644 --- a/services/users.js +++ b/services/users.js @@ -568,7 +568,7 @@ module.exports = class UsersService { } let redirectDomain; try { - redirectDomain = url.parse(loc).host; + redirectDomain = url.parse(loc).hostname; } catch (e) { return Promise.reject('redirect location is invalid'); }