diff --git a/client/coral-embed-stream/src/CommentStream.js b/client/coral-embed-stream/src/CommentStream.js index 7265c76b5..26142a311 100644 --- a/client/coral-embed-stream/src/CommentStream.js +++ b/client/coral-embed-stream/src/CommentStream.js @@ -1,11 +1,14 @@ import React, {Component, PropTypes} from 'react'; +import Pym from 'pym.js'; +import {connect} from 'react-redux'; + import { itemActions, Notification, notificationActions, authActions, } from '../../coral-framework'; -import {connect} from 'react-redux'; + import CommentBox from '../../coral-plugin-commentbox/CommentBox'; import InfoBox from '../../coral-plugin-infobox/InfoBox'; import Content from '../../coral-plugin-commentcontent/CommentContent'; @@ -13,44 +16,20 @@ import PubDate from '../../coral-plugin-pubdate/PubDate'; import Count from '../../coral-plugin-comment-count/CommentCount'; import AuthorName from '../../coral-plugin-author-name/AuthorName'; import {ReplyBox, ReplyButton} from '../../coral-plugin-replies'; -import Pym from 'pym.js'; import FlagButton from '../../coral-plugin-flags/FlagButton'; import LikeButton from '../../coral-plugin-likes/LikeButton'; import PermalinkButton from '../../coral-plugin-permalinks/PermalinkButton'; import SignInContainer from '../../coral-sign-in/containers/SignInContainer'; import UserBox from '../../coral-sign-in/components/UserBox'; -import {TabBar, Tab, TabContent} from '../../coral-ui'; +import {TabBar, Tab, TabContent, Spinner} from '../../coral-ui'; import SettingsContainer from '../../coral-settings/containers/SettingsContainer'; +import RestrictedContent from '../../coral-framework/components/RestrictedContent'; +import SuspendedAccount from '../../coral-framework/components/SuspendedAccount'; const {addItem, updateItem, postItem, getStream, postAction, deleteAction, appendItemArray} = itemActions; const {addNotification, clearNotification} = notificationActions; const {logout} = authActions; -const mapStateToProps = (state) => { - return { - config: state.config.toJS(), - items: state.items.toJS(), - notification: state.notification.toJS(), - auth: state.auth.toJS() - }; -}; - -const mapDispatchToProps = (dispatch) => ({ - addItem: (item, itemType) => dispatch(addItem(item, itemType)), - updateItem: (id, property, value, itemType) => dispatch(updateItem(id, property, value, itemType)), - postItem: (data, type, id) => dispatch(postItem(data, type, id)), - getStream: (rootId) => dispatch(getStream(rootId)), - addNotification: (type, text) => dispatch(addNotification(type, text)), - clearNotification: () => dispatch(clearNotification()), - postAction: (item, action, user, itemType) => dispatch(postAction(item, action, user, itemType)), - deleteAction: (item, action, user, itemType) => { - return dispatch(deleteAction(item, action, user, itemType)); - }, - appendItemArray: (item, property, value, addToFront, itemType) => - dispatch(appendItemArray(item, property, value, addToFront, itemType)), - logout: () => dispatch(logout()), -}); - class CommentStream extends Component { constructor (props) { @@ -89,17 +68,11 @@ class CommentStream extends Component { render () { if (Object.keys(this.props.items).length === 0) { - // Loading mock asset + // Loading mock asset this.props.postItem({ comments: [], url: 'http://coralproject.net' }, 'asset', 'assetTest'); - - // Loading mock user - //this.props.postItem({name: 'Ban Ki-Moon'}, 'user', 'user_8989') - // .then((id) => { - // this.props.setLoggedInUser(id); - // }); } // TODO: Replace teststream id with id from params @@ -109,71 +82,73 @@ class CommentStream extends Component { const {actions, users, comments} = this.props.items; const {loggedIn, user, showSignInDialog} = this.props.auth; const {activeTab} = this.state; + return
{ rootItem - ?
+ ?
Settings - - -
- - {loggedIn && } - - {!loggedIn && } -
- { - rootItem.comments && rootItem.comments.map((commentId) => { - const comment = comments[commentId]; - return
-
- - - -
- - -
-
- + {loggedIn && } + {/* Add to the restricted param a boolean if the user is suspended*/} + }> + +
+ + + {!loggedIn && } +
+ { + rootItem.comments && rootItem.comments.map((commentId) => { + const comment = comments[commentId]; + return
+
+ + + +
+ + +
+
+ -
+ commentId={commentId} + articleURL={this.path}/> +
{ let reply = this.props.items.comments[replyId]; - return
+ return

- - -
-
- - -
- + +
+
+ + +
+
; }) - } -
; - }) - } - - - - - + } +
; + }) + } +
+ + + {!loggedIn && } + + +
- : 'Loading' + : + }
; } } +const mapStateToProps = state => ({ + config: state.config.toJS(), + items: state.items.toJS(), + notification: state.notification.toJS(), + auth: state.auth.toJS(), + userData: state.user.toJS() +}); + +const mapDispatchToProps = (dispatch) => ({ + addItem: (item, itemType) => dispatch(addItem(item, itemType)), + updateItem: (id, property, value, itemType) => dispatch(updateItem(id, property, value, itemType)), + postItem: (data, type, id) => dispatch(postItem(data, type, id)), + getStream: (rootId) => dispatch(getStream(rootId)), + addNotification: (type, text) => dispatch(addNotification(type, text)), + clearNotification: () => dispatch(clearNotification()), + postAction: (item, action, user, itemType) => dispatch(postAction(item, action, user, itemType)), + deleteAction: (item, action, user, itemType) => dispatch(deleteAction(item, action, user, itemType)), + appendItemArray: (item, property, value, addToFront, itemType) => dispatch(appendItemArray(item, property, value, addToFront, itemType)), + handleSignInDialog: () => dispatch(authActions.showSignInDialog()), + logout: () => dispatch(logout()), +}); + export default connect(mapStateToProps, mapDispatchToProps)(CommentStream); diff --git a/client/coral-framework/actions/user.js b/client/coral-framework/actions/user.js index 0000acc5c..72075e6db 100644 --- a/client/coral-framework/actions/user.js +++ b/client/coral-framework/actions/user.js @@ -1,5 +1,10 @@ import * as actions from '../constants/user'; -import {base, handleResp, getInit} from '../helpers/response'; +import {addNotification} from '../actions/notification'; +import coralApi from '../helpers/response'; + +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from './../translations'; +const lang = new I18n(translations); const saveBioRequest = () => ({type: actions.SAVE_BIO_REQUEST}); const saveBioSuccess = settings => ({type: actions.SAVE_BIO_SUCCESS, settings}); @@ -7,9 +12,9 @@ const saveBioFailure = error => ({type: actions.SAVE_BIO_FAILURE, error}); export const saveBio = (user_id, formData) => dispatch => { dispatch(saveBioRequest()); - fetch(`${base}/user/${user_id}/bio`, getInit('PUT', formData)) - .then(handleResp) + coralApi(`/user/${user_id}/bio`, {method: 'PUT', body: formData}) .then(({settings}) => { + dispatch(addNotification('success', lang.t('successBioUpdate'))); dispatch(saveBioSuccess(settings)); }) .catch(error => dispatch(saveBioFailure(error))); diff --git a/client/coral-framework/components/RestrictedContent.js b/client/coral-framework/components/RestrictedContent.js index 8d019c996..32aaf632d 100644 --- a/client/coral-framework/components/RestrictedContent.js +++ b/client/coral-framework/components/RestrictedContent.js @@ -7,7 +7,7 @@ const lang = new I18n(translations); export default ({children, restricted, message = lang.t('contentNotAvailable'), restrictedComp}) => { if (restricted) { - return restrictedComp ? restrictedComp() : messageBox(message); + return restrictedComp ? restrictedComp : messageBox(message); } else { return (
diff --git a/client/coral-framework/components/SuspendedAccount.js b/client/coral-framework/components/SuspendedAccount.js new file mode 100644 index 000000000..5a23b77a2 --- /dev/null +++ b/client/coral-framework/components/SuspendedAccount.js @@ -0,0 +1,8 @@ +import React from 'react'; +import I18n from 'coral-framework/modules/i18n/i18n'; +import translations from 'coral-framework/translations.json'; +const lang = new I18n(translations); + +export default () => ( + {lang.t('suspendedAccountMsg')} +); diff --git a/client/coral-framework/translations.json b/client/coral-framework/translations.json index e2193f726..ab65ba565 100644 --- a/client/coral-framework/translations.json +++ b/client/coral-framework/translations.json @@ -1,5 +1,6 @@ { "en": { + "successBioUpdate": "Your Bio has been updated", "contentNotAvailable": "This content is not available", "suspendedAccountMsg": "Your account is currently suspended. This means that you cannot Like, Flag, or write comments. Please contact moderator@fakeurl.com for more information", "error": { @@ -12,6 +13,7 @@ } }, "es": { + "successBioUpdate": "Tu bio fue actualizada", "contentNotAvailable": "El contenido no se encuentra disponible", "suspendedAccountMsg": "Tu cuenta se encuentra suspendida. Esto significa que no puedes dar Like, Marcar o escribir commentarios. Por favor, contacta moderator@fakeurl for more information", "error": { diff --git a/client/coral-settings/components/Bio.js b/client/coral-settings/components/Bio.js index c142ee5bc..01489999f 100644 --- a/client/coral-settings/components/Bio.js +++ b/client/coral-settings/components/Bio.js @@ -2,14 +2,14 @@ import React from 'react'; import styles from './Bio.css'; import {Button} from '../../coral-ui'; -export default ({bio, handleSave, handleInput}) => ( +export default ({bio, handleSave, handleInput, handleCancel}) => (

Bio

Tell the community about yourself

-