2016-01-15 06:04:51 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
classNames = require 'classnames'
|
|
|
|
|
|
|
|
{ListTabular,
|
|
|
|
RetinaImg,
|
|
|
|
MailLabel,
|
|
|
|
MailImportantIcon,
|
|
|
|
InjectedComponentSet} = require 'nylas-component-kit'
|
|
|
|
|
|
|
|
{Thread,
|
2016-01-29 08:57:20 +08:00
|
|
|
AccountStore,
|
2016-01-15 06:04:51 +08:00
|
|
|
CategoryStore,
|
|
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
|
|
|
|
|
|
|
{ThreadArchiveQuickAction,
|
|
|
|
ThreadTrashQuickAction} = require './thread-list-quick-actions'
|
|
|
|
|
|
|
|
{timestamp,
|
|
|
|
subject} = require './formatting-utils'
|
|
|
|
|
|
|
|
ThreadListParticipants = require './thread-list-participants'
|
|
|
|
ThreadListStore = require './thread-list-store'
|
|
|
|
ThreadListIcon = require './thread-list-icon'
|
|
|
|
|
|
|
|
|
|
|
|
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} />
|
|
|
|
|
|
|
|
c3LabelComponentCache = {}
|
|
|
|
|
|
|
|
c3 = new ListTabular.Column
|
|
|
|
name: "Message"
|
|
|
|
flex: 4
|
|
|
|
resolver: (thread) =>
|
|
|
|
attachment = []
|
|
|
|
labels = []
|
2016-01-29 08:57:20 +08:00
|
|
|
|
2016-01-15 06:04:51 +08:00
|
|
|
if thread.hasAttachments
|
|
|
|
attachment = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
|
2016-01-29 08:57:20 +08:00
|
|
|
if AccountStore.accountForId(thread.accountId).usesLabels()
|
|
|
|
currentCategories = FocusedPerspectiveStore.current().categories() ? []
|
|
|
|
ignored = [].concat(currentCategories, CategoryStore.hiddenCategories(thread.accountId))
|
|
|
|
ignoredIds = _.pluck(ignored, 'id')
|
2016-01-15 06:04:51 +08:00
|
|
|
|
2016-01-29 08:57:20 +08:00
|
|
|
for label in (thread.sortedCategories())
|
|
|
|
continue if label.id in ignoredIds
|
|
|
|
c3LabelComponentCache[label.id] ?= <MailLabel label={label} key={label.id} />
|
|
|
|
labels.push c3LabelComponentCache[label.id]
|
2016-01-15 06:04:51 +08:00
|
|
|
|
|
|
|
<span className="details">
|
|
|
|
{labels}
|
|
|
|
<span className="subject">{subject(thread.subject)}</span>
|
|
|
|
<span className="snippet">{thread.snippet}</span>
|
|
|
|
{attachment}
|
|
|
|
</span>
|
|
|
|
|
|
|
|
c4 = new ListTabular.Column
|
|
|
|
name: "Date"
|
|
|
|
resolver: (thread) =>
|
|
|
|
<span className="timestamp">{timestamp(thread.lastMessageReceivedTimestamp)}</span>
|
|
|
|
|
|
|
|
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-02-12 07:24:33 +08:00
|
|
|
labels = []
|
|
|
|
if AccountStore.accountForId(thread.accountId).usesLabels()
|
|
|
|
currentCategories = FocusedPerspectiveStore.current().categories() ? []
|
|
|
|
ignored = [].concat(currentCategories, CategoryStore.hiddenCategories(thread.accountId))
|
|
|
|
ignoredIds = _.pluck(ignored, 'id')
|
|
|
|
|
|
|
|
for label in (thread.sortedCategories())
|
|
|
|
continue if label.id in ignoredIds
|
|
|
|
c3LabelComponentCache[label.id] ?= <MailLabel label={label} key={label.id} />
|
|
|
|
labels.push c3LabelComponentCache[label.id]
|
|
|
|
|
2016-01-15 06:04:51 +08:00
|
|
|
<div>
|
2016-02-12 07:24:33 +08:00
|
|
|
<div style={display: 'flex', alignItems: 'center'}>
|
2016-01-15 06:04:51 +08:00
|
|
|
<ThreadListIcon thread={thread} />
|
|
|
|
<ThreadListParticipants thread={thread} />
|
|
|
|
{pencil}
|
|
|
|
<span style={flex:1}></span>
|
|
|
|
{attachment}
|
|
|
|
<span className="timestamp">{timestamp(thread.lastMessageReceivedTimestamp)}</span>
|
|
|
|
</div>
|
2016-01-29 08:44:44 +08:00
|
|
|
<MailImportantIcon
|
|
|
|
thread={thread}
|
|
|
|
showIfAvailableForAnyAccount={true} />
|
2016-01-15 06:04:51 +08:00
|
|
|
<div className="subject">{subject(thread.subject)}</div>
|
2016-02-12 07:24:33 +08:00
|
|
|
<div className="snippet-and-labels">
|
|
|
|
<div className="snippet">{thread.snippet} </div>
|
|
|
|
<div style={flex: 1, flexShrink: 1}></div>
|
|
|
|
{labels}
|
|
|
|
</div>
|
2016-01-15 06:04:51 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
module.exports =
|
|
|
|
Narrow: [cNarrow]
|
|
|
|
Wide: [c1, c2, c3, c4, c5]
|