-
+
{lang.t('myProfile')}
Configure Stream
- {
- commentId &&
-
- {lang.t('showAllComments')}
-
- }
+ {commentId &&
+
+ {lang.t('showAllComments')}
+ }
+
- { loggedIn ? userBox : null }
- { loggedIn ? userBox : null }
@@ -81,5 +75,5 @@ Embed.propTypes = {
data: React.PropTypes.shape({
loading: React.PropTypes.bool,
error: React.PropTypes.object
- }).isRequired,
+ }).isRequired
};
diff --git a/client/coral-embed-stream/src/components/Stream.js b/client/coral-embed-stream/src/components/Stream.js
index be47b5c90..53f716954 100644
--- a/client/coral-embed-stream/src/components/Stream.js
+++ b/client/coral-embed-stream/src/components/Stream.js
@@ -1,22 +1,18 @@
import React, {PropTypes} from 'react';
-
-import {Button} from 'coral-ui';
import LoadMore from './LoadMore';
import NewCount from './NewCount';
+
import Comment from '../containers/Comment';
+import SuspendedAccount from './SuspendedAccount';
+import Slot from 'coral-framework/components/Slot';
import InfoBox from 'coral-plugin-infobox/InfoBox';
+import {can} from 'coral-framework/services/perms';
+import I18n from 'coral-framework/modules/i18n/i18n';
import {ModerationLink} from 'coral-plugin-moderation';
+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 SuspendedAccount from './SuspendedAccount';
-import RestrictedMessageBox
- from 'coral-framework/components/RestrictedMessageBox';
-import {can} from 'coral-framework/services/perms';
-import ChangeUsernameContainer
- from 'coral-sign-in/containers/ChangeUsernameContainer';
-import I18n from 'coral-framework/modules/i18n/i18n';
-import translations from 'coral-framework/translations';
const lang = new I18n(translations);
@@ -55,7 +51,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 &&
@@ -66,10 +65,15 @@ class Stream extends React.Component {
? 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);
+ return (
+ me &&
+ me.ignoredUsers &&
+ me.ignoredUsers.find((u) => u.id === comment.user.id)
+ );
};
return (
+
{open
?
:
{asset.settings.closedMessage}
}
- {!loggedIn &&
-
- Sign in to comment
- }
{loggedIn &&
- user &&
-
}
- {loggedIn &&
}
+
}
{/* the highlightedComment is isolated after the user followed a permalink */}
{highlightedComment
@@ -163,41 +159,38 @@ class Stream extends React.Component {
setCommentCountCache={this.props.setCommentCountCache}
/>
- {comments.map(
- (comment) => {
- return (commentIsIgnored(comment)
- ?
- :
- );
- }
- )}
+ {comments.map((comment) => {
+ return commentIsIgnored(comment)
+ ?
+ : ;
+ })}
-
-
-
-
-
-
-
- {lang.t('like')}
- thumb_up
-
-
-
{}}
- parentCommentId={'commentID'}
- currentUserId={{}}
- banned={false}
- />
-
-
-
-
- {lang.t('permalink.permalink')}
- link
-
-
-
-
- {lang.t('report')}
- flag
-
-
-
-
- );
- }
-}
-
-export default FakeComment;
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}) => (
-
-);
-
-export default UserBox;
diff --git a/client/coral-sign-in/containers/ChangeUsernameContainer.js b/client/coral-sign-in/containers/ChangeUsernameContainer.js
deleted file mode 100644
index cebd9605b..000000000
--- a/client/coral-sign-in/containers/ChangeUsernameContainer.js
+++ /dev/null
@@ -1,135 +0,0 @@
-import React, {Component} from 'react';
-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 I18n from 'coral-framework/modules/i18n/i18n';
-import translations from '../translations';
-const lang = new I18n(translations);
-
-import {
- showCreateUsernameDialog,
- hideCreateUsernameDialog,
- invalidForm,
- validForm,
- createUsername
-} from '../../coral-framework/actions/auth';
-
-class ChangeUsernameContainer extends Component {
- initialState = {
- formData: {
- username: '',
- },
- errors: {},
- showErrors: false
- };
-
- 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);
- }
-
- handleChange(e) {
- const {name, value} = e.target;
- this.setState((state) => ({
- ...state,
- formData: {
- ...state.formData,
- [name]: value
- }
- }), () => {
- this.validation(name, value);
- });
- }
-
- addError(name, error) {
- return this.setState((state) => ({
- errors: {
- ...state.errors,
- [name]: error
- }
- }));
- }
-
- validation(name, value) {
- const {addError} = this;
-
- if (!value.length) {
- addError(name, lang.t('createdisplay.requiredField'));
- } 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});
- }
-
- handleSubmitUsername(e) {
- e.preventDefault();
- const {errors} = this.state;
- const {validForm, invalidForm} = this.props;
- this.displayErrors();
- if (this.isCompleted() && !Object.keys(errors).length) {
- this.props.createUsername(this.props.user.id, this.state.formData);
- validForm();
- } else {
- invalidForm(lang.t('createdisplay.checkTheForm'));
- }
- }
-
- handleClose() {
- this.props.hideCreateUsernameDialog();
- }
-
- render() {
- const {loggedIn, auth} = this.props;
- return (
-
-
-
- );
- }
-}
-
-const mapStateToProps = (state) => ({
- auth: state.auth.toJS()
-});
-
-const mapDispatchToProps = (dispatch) => ({
- createUsername: (userid, formData) => dispatch(createUsername(userid, formData)),
- showCreateUsernameDialog: () => dispatch(showCreateUsernameDialog()),
- hideCreateUsernameDialog: () => dispatch(hideCreateUsernameDialog()),
- invalidForm: (error) => dispatch(invalidForm(error)),
- validForm: () => dispatch(validForm())
-});
-
-export default connect(
- mapStateToProps,
- mapDispatchToProps
-)(ChangeUsernameContainer);
diff --git a/client/coral-sign-in/containers/LoginContainer.js b/client/coral-sign-in/containers/LoginContainer.js
new file mode 100644
index 000000000..8d19e5198
--- /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 = () => (
+
+);
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/ChangeUsername.js b/plugins/coral-plugin-auth/client/components/ChangeUsername.js
new file mode 100644
index 000000000..9b0cbb1a6
--- /dev/null
+++ b/plugins/coral-plugin-auth/client/components/ChangeUsername.js
@@ -0,0 +1,132 @@
+import React from 'react';
+import {connect} from 'react-redux';
+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';
+
+const lang = new I18n(translations);
+
+import {
+ showCreateUsernameDialog,
+ hideCreateUsernameDialog,
+ invalidForm,
+ validForm,
+ createUsername
+} from 'coral-framework/actions/auth';
+
+class ChangeUsernameContainer extends React.Component {
+ constructor(props) {
+ super(props);
+
+ this.state = {
+ formData: {
+ username: props.user.username
+ },
+ errors: {},
+ showErrors: false
+ };
+ }
+
+ handleChange = e => {
+ const {name, value} = e.target;
+ this.setState(
+ state => ({
+ ...state,
+ formData: {
+ ...state.formData,
+ [name]: value
+ }
+ }),
+ () => {
+ this.validation(name, value);
+ }
+ );
+ };
+
+ addError = (name, error) => {
+ return this.setState(state => ({
+ errors: {
+ ...state.errors,
+ [name]: error
+ }
+ }));
+ };
+
+ validation = (name, value) => {
+ const {addError} = this;
+
+ if (!value.length) {
+ addError(name, lang.t('createdisplay.requiredField'));
+ } 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});
+ };
+
+ handleSubmitUsername = e => {
+ e.preventDefault();
+ const {errors} = this.state;
+ const {validForm, invalidForm} = this.props;
+ this.displayErrors();
+ if (this.isCompleted() && !Object.keys(errors).length) {
+ this.props.createUsername(this.props.user.id, this.state.formData);
+ validForm();
+ } else {
+ invalidForm(lang.t('createdisplay.checkTheForm'));
+ }
+ };
+
+ handleClose = () => {
+ this.props.hideCreateUsernameDialog();
+ };
+
+ render() {
+ const {loggedIn, auth} = this.props;
+ return (
+
+
+
+ );
+ }
+}
+
+const mapStateToProps = ({auth, user}) => ({auth, user});
+
+const mapDispatchToProps = dispatch =>
+ bindActionCreators(
+ {
+ createUsername,
+ showCreateUsernameDialog,
+ hideCreateUsernameDialog,
+ invalidForm,
+ validForm
+ },
+ dispatch
+ );
+
+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 61%
rename from client/coral-sign-in/components/CreateUsernameDialog.js
rename to plugins/coral-plugin-auth/client/components/CreateUsernameDialog.js
index b94b47c42..c352552ae 100644
--- a/client/coral-sign-in/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} }
+
- );
-};
+);
export default CreateUsernameDialog;
diff --git a/plugins/coral-plugin-auth/client/components/FakeComment.js b/plugins/coral-plugin-auth/client/components/FakeComment.js
new file mode 100644
index 000000000..01cc6863e
--- /dev/null
+++ b/plugins/coral-plugin-auth/client/components/FakeComment.js
@@ -0,0 +1,72 @@
+import React from 'react';
+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 styles from 'coral-embed-stream/src/components/Comment.css';
+
+const lang = new I18n(translations);
+
+export const FakeComment = ({username, created_at, body}) => (
+
+
+
+
+
+
+
+
+
+ {lang.t('like')}
+
+
+ thumb_up
+
+
+
+
{}}
+ parentCommentId={'commentID'}
+ currentUserId={{}}
+ banned={false}
+ />
+
+
+
+
+
+ {lang.t('permalink.permalink')}
+
+
+ link
+
+
+
+
+
+
+ {lang.t('report')}
+
+
+ flag
+
+
+
+
+
+);
\ No newline at end of file
diff --git a/client/coral-sign-in/components/ForgotContent.js b/plugins/coral-plugin-auth/client/components/ForgotContent.js
similarity index 50%
rename from client/coral-sign-in/components/ForgotContent.js
rename to plugins/coral-plugin-auth/client/components/ForgotContent.js
index 76246fa00..2099330bc 100644
--- a/client/coral-sign-in/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 {
{lang.t('signIn.email')}
this.emailInput = input}
+ ref={input => (this.emailInput = input)}
type="text"
style={{fontSize: 16}}
id="email"
- name="email" />
+ name="email"
+ />
-
+
{lang.t('signIn.recoverPassword')}
- {
- passwordRequestSuccess
- ? {passwordRequestSuccess}
- : null
- }
- {
- passwordRequestFailure
- ? {passwordRequestFailure}
- : null
- }
+ {passwordRequestSuccess
+ ?
+ {passwordRequestSuccess}
+
+ : null}
+ {passwordRequestFailure
+ ?
+ {passwordRequestFailure}
+
+ : null}
);
diff --git a/client/coral-sign-in/components/SignDialog.js b/plugins/coral-plugin-auth/client/components/SignDialog.js
similarity index 68%
rename from client/coral-sign-in/components/SignDialog.js
rename to plugins/coral-plugin-auth/client/components/SignDialog.js
index ff2464f7c..7f05889a0 100644
--- a/client/coral-sign-in/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}) => (
-