import React, { PropTypes } from 'react' import ProfileImage from 'boost/components/ProfileImage' import ModeIcon from 'boost/components/ModeIcon' import moment from 'moment' import { switchArticle, NEW } from 'boost/actions' import FolderMark from 'boost/components/FolderMark' export default class ArticleList extends React.Component { handleArticleClick (key) { let { dispatch } = this.props return function (e) { dispatch(switchArticle(key)) } } render () { let { articles, activeArticle } = this.props console.log(articles) let articlesEl = articles.map(article => { let tags = Array.isArray(article.Tags) && article.Tags.length > 0 ? article.Tags.map(tag => { return ({tag.name}) }) : (Not tagged yet) return (
this.handleArticleClick(article.key)(e)} className={'articleItem' + (activeArticle.key === article.key ? ' active' : '')}>
by {article.User.profileName} {article.status != null ? article.status : moment(article.updatedAt).fromNow()}
{article.status !== NEW ? article.title : '(New article)'}
{tags}
) }) return (
{articlesEl}
) } } ArticleList.propTypes = { articles: PropTypes.array, activeArticle: PropTypes.shape(), dispatch: PropTypes.func }