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
-
-
-
- {
- rootItem.comments && rootItem.comments.map((commentId) => {
- const comment = comments[commentId];
- 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
diff --git a/client/coral-settings/components/NotLoggedIn.js b/client/coral-settings/components/NotLoggedIn.js
index d80aed8ab..d7bf467e8 100644
--- a/client/coral-settings/components/NotLoggedIn.js
+++ b/client/coral-settings/components/NotLoggedIn.js
@@ -1,10 +1,10 @@
import React from 'react';
import styles from './NotLoggedIn.css';
-export default () => (
+export default ({showSignInDialog}) => (
From the Settings Page you can
diff --git a/client/coral-settings/containers/BioContainer.js b/client/coral-settings/containers/BioContainer.js
index ca4373644..b7c9611d4 100644
--- a/client/coral-settings/containers/BioContainer.js
+++ b/client/coral-settings/containers/BioContainer.js
@@ -5,29 +5,41 @@ export default class BioContainer extends Component {
constructor (props) {
super(props);
+ this.state = {
+ bio: props.bio
+ };
+
this.handleSave = this.handleSave.bind(this);
this.handleInput = this.handleInput.bind(this);
+ this.handleCancel = this.handleCancel.bind(this);
}
- handleInput(input) {
- this.bioInput = input;
+ handleInput(e) {
+ this.setState({
+ bio: e.target.value
+ });
}
handleSave (e) {
e.preventDefault();
const {userData, saveBio} = this.props;
- saveBio(userData.id, {
- bio: this.bioInput.value
+ const {bio} = this.state;
+ saveBio(userData.id, {bio});
+ }
+
+ handleCancel () {
+ this.setState({
+ bio: this.props.bio
});
}
render () {
- const {bio, userData} = this.props;
return
;
}
}
diff --git a/client/coral-settings/containers/SettingsContainer.js b/client/coral-settings/containers/SettingsContainer.js
index fc196b9e7..96020a10c 100644
--- a/client/coral-settings/containers/SettingsContainer.js
+++ b/client/coral-settings/containers/SettingsContainer.js
@@ -31,10 +31,10 @@ class SignInContainer extends Component {
}
render() {
- const {loggedIn, userData} = this.props;
+ const {loggedIn, userData, showSignInDialog} = this.props;
const {activeTab} = this.state;
return (
-
+ }>
All Comments (120)
diff --git a/client/coral-sign-in/containers/SignInContainer.js b/client/coral-sign-in/containers/SignInContainer.js
index c2b8c7836..c201a3863 100644
--- a/client/coral-sign-in/containers/SignInContainer.js
+++ b/client/coral-sign-in/containers/SignInContainer.js
@@ -129,12 +129,10 @@ class SignInContainer extends Component {
}
render() {
- const {auth, showSignInDialog} = this.props;
+ const {auth, showSignInDialog, noButton} = this.props;
return (
-
- Sign in to comment
-
+ {!noButton && Sign in to comment }