_ = require 'underscore-plus'
React = require "react"
module.exports =
MessageParticipants = React.createClass
displayName: 'MessageParticipants'
render: ->
classSet = React.addons.classSet
"participants": true
"message-participants": true
"collapsed": not @props.isDetailed
{if @props.isDetailed then @_renderExpanded() else @_renderCollapsed()}
_renderCollapsed: ->
{@_shortNames(@props.from)}
>
{@_shortNames(@props.to)}
0 then display:"inline" else display:"none"}>
Cc:
{@_shortNames(@props.cc)}
_renderExpanded: ->
From:
{@_fullContact(@props.from)}
To:
{@_fullContact(@props.to)}
0 then display:"block" else display:"none"}>
Cc:
{@_fullContact(@props.cc)}
_shortNames: (contacts=[]) ->
_.map(contacts, (c) -> c.displayFirstName()).join(", ")
_fullContact: (contacts=[]) ->
_.map(contacts, (c) ->
if c.name?.length > 0 and c.name isnt c.email
{c.name}
<{c.email}>
else
{c.email}
)