Loading settings and modifying commentbox to reflect pre and post-mod behavior.

This commit is contained in:
David Jay
2016-11-10 17:04:04 -05:00
parent 26f48196d9
commit 0ce892fe7a
6 changed files with 33 additions and 26 deletions
@@ -108,6 +108,7 @@ class CommentStream extends Component {
appendItemArray={this.props.appendItemArray}
updateItem={this.props.updateItem}
id={rootItemId}
premod={this.props.config.moderation}
reply={false}/>
</div>
{
@@ -138,6 +139,7 @@ class CommentStream extends Component {
updateItem={this.props.updateItem}
id={rootItemId}
parent_id={commentId}
premod={this.props.config.moderation}
showReply={comment.showReply}/>
{
comment.children &&
@@ -168,7 +170,7 @@ class CommentStream extends Component {
})
}
<Notification
notifLength={this.props.config.notifLength}
notifLength={4500}
clearNotification={this.props.clearNotification}
notification={this.props.notification}/>
</div>
+20 -14
View File
@@ -14,17 +14,23 @@ export const FETCH_CONFIG_SUCCESS = 'FETCH_CONFIG_SUCCESS';
* Action creators
*/
export const fetchConfig = () => async (dispatch) => {
dispatch({type: FETCH_CONFIG_REQUEST});
try {
//TODO: Replace with fetching config from backend
// const response = await fetch(`./talk.config.json`)
// const json = await response.json()
dispatch({type: FETCH_CONFIG_SUCCESS, config: fromJS({
notifLength: 4500
})});
} catch (error) {
dispatch({type: FETCH_CONFIG_FAILED});
}
};
export function fetchConfig () {
return (dispatch) => {
dispatch({type: FETCH_CONFIG_REQUEST});
console.log('Fetching settings');
return fetch('/api/v1/settings')
.then(
response => {
return response.ok ? response.json()
: Promise.reject(`${response.status} ${response.statusText}`);
}
)
.then((json) => {
console.log(json);
return dispatch({type: FETCH_CONFIG_SUCCESS, config: fromJS(json)});
}).catch((error) => {
console.log(error);
dispatch({type: FETCH_CONFIG_FAILED, error});
});
};
}
@@ -148,7 +148,7 @@ export function getStream (assetId) {
export function getItemsArray (ids) {
return (dispatch) => {
return fetch(`/v1/item/${ ids}`)
return fetch(`/v1/item/${ids}`)
.then(
response => {
return response.ok ? response.json()
@@ -2,7 +2,7 @@ import React from 'react';
const packagename = 'coral-plugin-author-name';
const AuthorName = ({name}) =>
<div className={`${packagename }-text`}>
<div className={`${packagename}-text`}>
{name}
</div>;
+7 -3
View File
@@ -19,7 +19,7 @@ class CommentBox extends Component {
}
postComment = () => {
const {postItem, updateItem, id, parent_id, addNotification, appendItemArray} = this.props;
const {postItem, updateItem, id, parent_id, addNotification, appendItemArray, premod} = this.props;
let comment = {
body: this.state.body,
asset_id: id,
@@ -38,8 +38,12 @@ class CommentBox extends Component {
updateItem(parent_id, 'showReply', false, 'comments');
postItem(comment, 'comments')
.then((comment_id) => {
appendItemArray(parent_id || id, related, comment_id, !parent_id, parent_type);
addNotification('success', 'Your comment has been posted.');
if (premod === 'pre') {
addNotification('success', 'Your comment has been posted and is being reviewed by our moderation team.');
} else {
appendItemArray(parent_id || id, related, comment_id, !parent_id, parent_type);
addNotification('success', 'Your comment has been posted.');
}
}).catch((err) => console.error(err));
this.setState({body: ''});
}
+1 -6
View File
@@ -8,12 +8,7 @@ const ReplyBox = (props) => <div
style={props.styles && props.styles.container}>
{
props.showReply && <CommentBox
id = {props.id}
parent_id = {props.parent_id}
postItem = {props.postItem}
addNotification = {props.addNotification}
appendItemArray = {props.appendItemArray}
updateItem = {props.updateItem}
{...props}
comments = {props.child}
reply = {true}/>
}