import React from 'react'; import timeago from 'timeago.js'; import Linkify from 'react-linkify'; import styles from './ModerationList.css'; import I18n from 'coral-framework/modules/i18n/i18n'; import translations from '../translations.json'; import {Icon} from 'react-mdl'; import Highlighter from 'react-highlight-words'; import {FabButton, Button} from 'coral-ui'; const linkify = new Linkify(); // Render a single comment for the list const Comment = props => { const {comment, author} = props; let authorStatus = author.status; const links = linkify.getMatches(comment.body); return (
  • person {author.displayName || lang.t('comment.anon')} {timeago().format(comment.createdAt || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} {comment.flagged ?

    {lang.t('comment.flagged')}

    : null}
    {links ? Contains Link : null}
    {props.modActions.map((action, i) => getActionButton(action, i, props))}
    {authorStatus === 'banned' ? {lang.t('comment.banned_user')} : null}
  • ); }; // Get the button of the action performed over a comment if any const getActionButton = (option, i, props) => { const {comment, author, menuOptionsMap} = props; const status = comment.status; const flagged = comment.flagged; const banned = (author.status === 'banned'); if (option === 'flag' && (status || flagged === true)) { return null; } if (option === 'ban') { return ( ); } const menuOption = menuOptionsMap[option]; return ( props.onClickAction(menuOption.status, comment, {item_type: 'comment'})} /> ); }; export default Comment; const linkStyles = { backgroundColor: 'rgb(255, 219, 135)', padding: '1px 2px' }; const lang = new I18n(translations);