2016-01-26 08:36:56 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
classNames = require 'classnames'
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
{ListTabular,
|
|
|
|
InjectedComponent,
|
|
|
|
Flexbox} = require 'nylas-component-kit'
|
|
|
|
|
2016-01-26 08:36:56 +08:00
|
|
|
{timestamp,
|
|
|
|
subject} = require './formatting-utils'
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
{Actions} = require 'nylas-exports'
|
|
|
|
SendingProgressBar = require './sending-progress-bar'
|
|
|
|
SendingCancelButton = require './sending-cancel-button'
|
|
|
|
|
2016-01-26 08:36:56 +08:00
|
|
|
snippet = (html) =>
|
|
|
|
return "" unless html and typeof(html) is 'string'
|
|
|
|
try
|
|
|
|
@draftSanitizer ?= document.createElement('div')
|
|
|
|
@draftSanitizer.innerHTML = html[0..400]
|
|
|
|
text = @draftSanitizer.innerText
|
|
|
|
text[0..200]
|
|
|
|
catch
|
|
|
|
return ""
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
ParticipantsColumn = new ListTabular.Column
|
|
|
|
name: "Participants"
|
2016-01-26 08:36:56 +08:00
|
|
|
width: 200
|
|
|
|
resolver: (draft) =>
|
2016-02-05 06:14:24 +08:00
|
|
|
list = [].concat(draft.to, draft.cc, draft.bcc)
|
|
|
|
|
|
|
|
if list.length > 0
|
|
|
|
<div className="participants">
|
|
|
|
{list.map (p) => <span key={p.email}>{p.displayName()}</span>}
|
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<div className="participants no-recipients">
|
|
|
|
(No Recipients)
|
|
|
|
</div>
|
2016-01-26 08:36:56 +08:00
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
ContentsColumn = new ListTabular.Column
|
|
|
|
name: "Contents"
|
2016-01-26 08:36:56 +08:00
|
|
|
flex: 4
|
|
|
|
resolver: (draft) =>
|
|
|
|
attachments = []
|
|
|
|
if draft.files?.length > 0
|
|
|
|
attachments = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
<span className="details">
|
|
|
|
<span className="subject">{subject(draft.subject)}</span>
|
|
|
|
<span className="snippet">{snippet(draft.body)}</span>
|
|
|
|
{attachments}
|
|
|
|
</span>
|
|
|
|
|
2016-02-05 06:14:24 +08:00
|
|
|
SendStateColumn = new ListTabular.Column
|
|
|
|
name: "State"
|
2016-01-26 08:36:56 +08:00
|
|
|
resolver: (draft) =>
|
2016-02-05 06:14:24 +08:00
|
|
|
if draft.uploadTaskId
|
|
|
|
<Flexbox style={width:150, whiteSpace: 'no-wrap'}>
|
|
|
|
<SendingProgressBar style={flex: 1, marginRight: 10} progress={draft.uploadProgress * 100} />
|
|
|
|
<SendingCancelButton taskId={draft.uploadTaskId} />
|
|
|
|
</Flexbox>
|
|
|
|
else
|
|
|
|
<span className="timestamp">{timestamp(draft.date)}</span>
|
2016-01-26 08:36:56 +08:00
|
|
|
|
|
|
|
module.exports =
|
2016-02-05 06:14:24 +08:00
|
|
|
Wide: [ParticipantsColumn, ContentsColumn, SendStateColumn]
|