import React from 'react'; import {Button, Icon} from 'react-mdl'; import timeago from 'timeago.js'; import styles from './CommentList.css'; import I18n from 'coral-framework/i18n/i18n'; import translations from '../translations.json'; // Render a single comment for the list export default props => (
  • person {props.comment.get('name') || lang.t('comment.anon')} {timeago().format(props.comment.get('createdAt') || (Date.now() - props.index * 60 * 1000), lang.getLocale().replace('-', '_'))} {props.comment.get('flagged') ?

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

    : null}
    {props.actions.map(action => canShowAction(action, props.comment) ? ( ) : null)}
    {props.comment.get('body')}
  • ); // Check if an action can be performed over a comment const canShowAction = (action, comment) => { const status = comment.get('status'); const flagged = comment.get('flagged'); if (action === 'flag' && (status || flagged === true)) { return false; } return true; }; const lang = new I18n(translations);