import React from 'react' import { connect } from 'react-redux' import ModerationKeysModal from 'components/ModerationKeysModal' import CommentList from 'components/CommentList' import { updateStatus } from 'actions/comments' import styles from './ModerationQueue.css' import key from 'keymaster' import I18n from 'coral-framework/i18n/i18n' import translations from '../translations' /* * Renders the moderation queue as a tabbed layout with 3 moderation * queues filtered by status (Untouched, Rejected and Approved) */ class ModerationQueue extends React.Component { constructor (props) { super(props) console.log('ModerationQueue', props) this.state = { activeTab: 'pending', singleView: false, modalOpen: false } } // Fetch comments and bind singleView key before render componentWillMount () { this.props.dispatch({ type: 'COMMENTS_MODERATION_QUEUE_FETCH' }) key('s', () => this.setState({ singleView: !this.state.singleView })) key('shift+/', () => this.setState({ modalOpen: true })) key('esc', () => this.setState({ modalOpen: false })) } // Unbind singleView key before unmount componentWillUnmount () { key.unbind('s') key.unbind('shift+/') key.unbind('esc') } // Hack for dynamic mdl tabs componentDidMount () { if (typeof componentHandler !== 'undefined') { componentHandler.upgradeAllRegistered() } } // Dispatch the update status action onCommentAction (status, id) { this.props.dispatch(updateStatus(status, id)) } onTabClick (activeTab) { this.setState({ activeTab }) } // Render the tabbed lists moderation queues render () { const { comments } = this.props const { activeTab, singleView, modalOpen } = this.state return (