2016-01-15 06:04:51 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
classNames = require 'classnames'
|
|
|
|
|
|
|
|
{ListTabular,
|
|
|
|
RetinaImg,
|
2016-03-03 02:05:17 +08:00
|
|
|
MailLabelSet,
|
2016-01-15 06:04:51 +08:00
|
|
|
MailImportantIcon,
|
|
|
|
InjectedComponentSet} = require 'nylas-component-kit'
|
|
|
|
|
2016-03-18 00:50:30 +08:00
|
|
|
{Thread, FocusedPerspectiveStore, Utils} = require 'nylas-exports'
|
2016-01-15 06:04:51 +08:00
|
|
|
|
|
|
|
{ThreadArchiveQuickAction,
|
|
|
|
ThreadTrashQuickAction} = require './thread-list-quick-actions'
|
|
|
|
|
|
|
|
ThreadListParticipants = require './thread-list-participants'
|
|
|
|
ThreadListStore = require './thread-list-store'
|
|
|
|
ThreadListIcon = require './thread-list-icon'
|
|
|
|
|
2016-03-10 03:40:35 +08:00
|
|
|
TimestampComponentForPerspective = (thread) ->
|
|
|
|
if FocusedPerspectiveStore.current().isSent()
|
2016-03-18 00:50:30 +08:00
|
|
|
<span className="timestamp">{Utils.shortTimeString(thread.lastMessageSentTimestamp)}</span>
|
|
|
|
else
|
|
|
|
<span className="timestamp">{Utils.shortTimeString(thread.lastMessageReceivedTimestamp)}</span>
|
|
|
|
|
|
|
|
subject = (subj) ->
|
|
|
|
if (subj ? "").trim().length is 0
|
|
|
|
return <span className="no-subject">(No Subject)</span>
|
2016-03-27 03:14:29 +08:00
|
|
|
else if subj.split(/([\uD800-\uDBFF][\uDC00-\uDFFF])/g).length > 1
|
|
|
|
subjComponents = []
|
|
|
|
subjParts = subj.split /([\uD800-\uDBFF][\uDC00-\uDFFF])/g
|
|
|
|
for part in subjParts
|
|
|
|
if part.match /([\uD800-\uDBFF][\uDC00-\uDFFF])/g
|
|
|
|
subjComponents.push <span className="emoji">{part}</span>
|
|
|
|
else
|
|
|
|
subjComponents.push <span>{part}</span>
|
|
|
|
return subjComponents
|
2016-03-10 03:40:35 +08:00
|
|
|
else
|
2016-03-18 00:50:30 +08:00
|
|
|
return subj
|
2016-03-10 03:40:35 +08:00
|
|
|
|
2016-01-15 06:04:51 +08:00
|
|
|
|
|
|
|
c1 = new ListTabular.Column
|
|
|
|
name: "★"
|
|
|
|
resolver: (thread) =>
|
|
|
|
[
|
|
|
|
<ThreadListIcon key="thread-list-icon" thread={thread} />
|
2016-01-29 08:44:44 +08:00
|
|
|
<MailImportantIcon
|
|
|
|
key="mail-important-icon"
|
|
|
|
thread={thread}
|
|
|
|
showIfAvailableForAnyAccount={true} />
|
2016-01-15 06:04:51 +08:00
|
|
|
<InjectedComponentSet
|
|
|
|
key="injected-component-set"
|
|
|
|
inline={true}
|
|
|
|
containersRequired={false}
|
|
|
|
matching={role: "ThreadListIcon"}
|
|
|
|
className="thread-injected-icons"
|
|
|
|
exposedProps={thread: thread}/>
|
|
|
|
]
|
|
|
|
|
|
|
|
c2 = new ListTabular.Column
|
|
|
|
name: "Participants"
|
|
|
|
width: 200
|
|
|
|
resolver: (thread) =>
|
|
|
|
hasDraft = _.find (thread.metadata ? []), (m) -> m.draft
|
|
|
|
if hasDraft
|
|
|
|
<div style={display: 'flex'}>
|
|
|
|
<ThreadListParticipants thread={thread} />
|
|
|
|
<RetinaImg name="icon-draft-pencil.png"
|
|
|
|
className="draft-icon"
|
|
|
|
mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
</div>
|
|
|
|
else
|
|
|
|
<ThreadListParticipants thread={thread} />
|
|
|
|
|
|
|
|
c3 = new ListTabular.Column
|
|
|
|
name: "Message"
|
|
|
|
flex: 4
|
|
|
|
resolver: (thread) =>
|
|
|
|
attachment = []
|
|
|
|
if thread.hasAttachments
|
|
|
|
attachment = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
|
|
|
|
<span className="details">
|
2016-03-03 02:05:17 +08:00
|
|
|
<MailLabelSet thread={thread} />
|
2016-01-15 06:04:51 +08:00
|
|
|
<span className="subject">{subject(thread.subject)}</span>
|
|
|
|
<span className="snippet">{thread.snippet}</span>
|
|
|
|
{attachment}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
c4 = new ListTabular.Column
|
|
|
|
name: "Date"
|
|
|
|
resolver: (thread) =>
|
2016-03-10 03:40:35 +08:00
|
|
|
TimestampComponentForPerspective(thread)
|
2016-01-15 06:04:51 +08:00
|
|
|
|
|
|
|
c5 = new ListTabular.Column
|
|
|
|
name: "HoverActions"
|
|
|
|
resolver: (thread) =>
|
|
|
|
<div className="inner">
|
|
|
|
<InjectedComponentSet
|
|
|
|
key="injected-component-set"
|
|
|
|
inline={true}
|
|
|
|
containersRequired={false}
|
|
|
|
children=
|
|
|
|
{[
|
|
|
|
<ThreadTrashQuickAction key="thread-trash-quick-action" thread={thread} />
|
2016-02-05 06:14:24 +08:00
|
|
|
<ThreadArchiveQuickAction key="thread-archive-quick-action" thread={thread} />
|
2016-01-15 06:04:51 +08:00
|
|
|
]}
|
|
|
|
matching={role: "ThreadListQuickAction"}
|
|
|
|
className="thread-injected-quick-actions"
|
|
|
|
exposedProps={thread: thread}/>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
cNarrow = new ListTabular.Column
|
|
|
|
name: "Item"
|
|
|
|
flex: 1
|
|
|
|
resolver: (thread) =>
|
|
|
|
pencil = []
|
|
|
|
attachment = []
|
|
|
|
hasDraft = _.find (thread.metadata ? []), (m) -> m.draft
|
|
|
|
if thread.hasAttachments
|
|
|
|
attachment = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
if hasDraft
|
|
|
|
pencil = <RetinaImg name="icon-draft-pencil.png" className="draft-icon" mode={RetinaImg.Mode.ContentPreserve} />
|
|
|
|
|
2016-03-25 03:32:01 +08:00
|
|
|
# TODO We are limiting the amount on injected icons in narrow mode to 1
|
|
|
|
# until we revisit the UI to accommodate more icons
|
2016-03-25 02:59:12 +08:00
|
|
|
<div style={display: 'flex', alignItems: 'flex-start'}>
|
|
|
|
<div className="icons-column">
|
2016-01-15 06:04:51 +08:00
|
|
|
<ThreadListIcon thread={thread} />
|
2016-03-25 02:59:12 +08:00
|
|
|
<InjectedComponentSet
|
|
|
|
inline={true}
|
2016-03-25 03:32:01 +08:00
|
|
|
matchLimit={1}
|
2016-03-25 02:59:12 +08:00
|
|
|
direction="column"
|
|
|
|
containersRequired={false}
|
2016-03-25 03:32:01 +08:00
|
|
|
key="injected-component-set"
|
|
|
|
exposedProps={thread: thread}
|
2016-03-25 02:59:12 +08:00
|
|
|
matching={role: "ThreadListIcon"}
|
|
|
|
className="thread-injected-icons"
|
|
|
|
/>
|
|
|
|
<MailImportantIcon
|
|
|
|
thread={thread}
|
|
|
|
showIfAvailableForAnyAccount={true}
|
|
|
|
/>
|
2016-01-15 06:04:51 +08:00
|
|
|
</div>
|
2016-03-25 02:59:12 +08:00
|
|
|
<div className="thread-info-column">
|
|
|
|
<div className="participants-wrapper">
|
|
|
|
<ThreadListParticipants thread={thread} />
|
|
|
|
{pencil}
|
|
|
|
<span style={flex:1}></span>
|
|
|
|
{attachment}
|
|
|
|
{TimestampComponentForPerspective(thread)}
|
|
|
|
</div>
|
|
|
|
<div className="subject">{subject(thread.subject)}</div>
|
|
|
|
<div className="snippet-and-labels">
|
|
|
|
<div className="snippet">{thread.snippet} </div>
|
|
|
|
<div style={flex: 1, flexShrink: 1}></div>
|
|
|
|
<MailLabelSet thread={thread} />
|
|
|
|
</div>
|
2016-02-12 07:24:33 +08:00
|
|
|
</div>
|
2016-01-15 06:04:51 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
Narrow: [cNarrow]
|
|
|
|
Wide: [c1, c2, c3, c4, c5]
|