mirror of
https://github.com/wassname/talk.git
synced 2026-08-08 11:28:12 +08:00
add propTypes to CommentList
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
|
||||
import React from 'react';
|
||||
import React, {PropTypes} from 'react';
|
||||
import styles from './CommentList.css';
|
||||
import key from 'keymaster';
|
||||
import Hammer from 'hammerjs';
|
||||
@@ -15,6 +14,28 @@ const actions = {
|
||||
|
||||
// Renders a comment list and allow performing actions
|
||||
export default class CommentList extends React.Component {
|
||||
static propTypes = {
|
||||
isActive: PropTypes.bool,
|
||||
singleView: PropTypes.bool,
|
||||
commentIds: PropTypes.arrayOf(PropTypes.string).isRequired,
|
||||
comments: PropTypes.object.isRequired,
|
||||
users: PropTypes.object.isRequired,
|
||||
onClickAction: PropTypes.func,
|
||||
actions: PropTypes.arrayOf(PropTypes.string),
|
||||
loading: PropTypes.bool,
|
||||
// list of actions (flags, etc) associated with the comments
|
||||
commentActions: PropTypes.arrayOf(
|
||||
PropTypes.shape({
|
||||
action_type: PropTypes.string,
|
||||
count: PropTypes.number,
|
||||
current_user: PropTypes.string,
|
||||
item_id: PropTypes.string,
|
||||
item_type: PropTypes.string
|
||||
})
|
||||
),
|
||||
suspectWords: PropTypes.arrayOf(PropTypes.string)
|
||||
}
|
||||
|
||||
constructor (props) {
|
||||
super(props);
|
||||
|
||||
@@ -122,7 +143,7 @@ export default class CommentList extends React.Component {
|
||||
}
|
||||
|
||||
render () {
|
||||
const {singleView, commentIds, comments, users, hideActive, key} = this.props;
|
||||
const {singleView, commentIds, comments, users, hideActive, key, suspectWords, commentActions} = this.props;
|
||||
const {active} = this.state;
|
||||
|
||||
return (
|
||||
@@ -130,7 +151,11 @@ export default class CommentList extends React.Component {
|
||||
{commentIds.map((commentId, index) => {
|
||||
const comment = comments[commentId];
|
||||
const author = users[comment.author_id];
|
||||
return <Comment comment={comment}
|
||||
const localActions = commentActions.filter(action => action.item_id === commentId);
|
||||
return <Comment
|
||||
commentActions={localActions}
|
||||
suspectWords={suspectWords}
|
||||
comment={comment}
|
||||
author={author}
|
||||
key={index}
|
||||
index={index}
|
||||
|
||||
@@ -83,9 +83,11 @@ class ModerationQueue extends React.Component {
|
||||
|
||||
// Render the tabbed lists moderation queues
|
||||
render () {
|
||||
const {comments, users} = this.props;
|
||||
const {comments, users, settings} = this.props;
|
||||
const {activeTab, singleView, modalOpen} = this.state;
|
||||
|
||||
console.log('ModerationQueue comments', comments);
|
||||
|
||||
const premodIds = comments.ids.filter(id => comments.byId[id].status === 'premod');
|
||||
const rejectedIds = comments.ids.filter(id => comments.byId[id].status === 'rejected');
|
||||
const flaggedIds = comments.ids.filter(id => comments.byId[id].flagged === true);
|
||||
@@ -108,6 +110,8 @@ class ModerationQueue extends React.Component {
|
||||
</div>
|
||||
<div className={`mdl-tabs__panel is-active ${styles.listContainer}`} id='pending'>
|
||||
<CommentList
|
||||
suspectWords={['fishy', 'shady']}
|
||||
commentActions={[]}
|
||||
isActive={activeTab === 'pending'}
|
||||
singleView={singleView}
|
||||
commentIds={premodIds}
|
||||
@@ -125,6 +129,7 @@ class ModerationQueue extends React.Component {
|
||||
</div>
|
||||
<div className={`mdl-tabs__panel ${styles.listContainer}`} id='rejected'>
|
||||
<CommentList
|
||||
commentActions={[]}
|
||||
isActive={activeTab === 'rejected'}
|
||||
singleView={singleView}
|
||||
commentIds={rejectedIds}
|
||||
@@ -136,6 +141,7 @@ class ModerationQueue extends React.Component {
|
||||
</div>
|
||||
<div className={`mdl-tabs__panel ${styles.listContainer}`} id='flagged'>
|
||||
<CommentList
|
||||
commentActions={[]}
|
||||
isActive={activeTab === 'flagged'}
|
||||
singleView={singleView}
|
||||
commentIds={flaggedIds}
|
||||
@@ -157,6 +163,7 @@ class ModerationQueue extends React.Component {
|
||||
}
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
settings: state.settings.toJS(),
|
||||
comments: state.comments.toJS(),
|
||||
users: state.users.toJS()
|
||||
});
|
||||
|
||||
@@ -49,9 +49,9 @@
|
||||
"comment-settings": "Comment Settings",
|
||||
"embed-comment-stream": "Embed Comment Stream",
|
||||
"banned-word-header": "Write the bannned words list",
|
||||
"banned-word-text": "Comments which contain these words or phrases, not separated by commas and not case-sensitive, will be automatically removed from the comment stream.",
|
||||
"banned-word-text": "Comments which contain these words or phrases (not case-sensitive) will be automatically removed from the comment stream.",
|
||||
"suspect-word-header": "Write the suspect words list",
|
||||
"suspect-word-text": "Comments which contain these words or phrases, not separated by commas and not case-sensitive will be highlighted in the comment stream",
|
||||
"suspect-word-text": "Comments which contain these words or phrases (not case-sensitive) will be highlighted in the comment stream",
|
||||
"wordlist": "Banned & Suspect Words",
|
||||
"banned-words-title": "Banned words list",
|
||||
"suspect-words-title": "Suspect words list",
|
||||
|
||||
Reference in New Issue
Block a user