2015-03-10 09:25:53 +08:00
|
|
|
_ = require 'underscore-plus'
|
|
|
|
React = require 'react'
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
{ListTabular, MultiselectList} = require 'ui-components'
|
2015-03-10 09:25:53 +08:00
|
|
|
{timestamp, subject} = require './formatting-utils'
|
2015-03-26 02:17:57 +08:00
|
|
|
{Actions,
|
2015-03-26 03:41:48 +08:00
|
|
|
Utils,
|
2015-04-07 02:46:20 +08:00
|
|
|
Thread,
|
2015-03-26 02:17:57 +08:00
|
|
|
WorkspaceStore,
|
2015-03-26 03:41:48 +08:00
|
|
|
NamespaceStore} = require 'inbox-exports'
|
|
|
|
|
|
|
|
ThreadListParticipants = require './thread-list-participants'
|
2015-04-09 10:25:00 +08:00
|
|
|
ThreadListStore = require './thread-list-store'
|
2015-03-10 09:25:53 +08:00
|
|
|
|
|
|
|
module.exports =
|
|
|
|
ThreadList = React.createClass
|
|
|
|
displayName: 'ThreadList'
|
|
|
|
|
2015-04-07 02:46:20 +08:00
|
|
|
componentWillMount: ->
|
2015-03-10 09:25:53 +08:00
|
|
|
labelComponents = (thread) =>
|
|
|
|
for label in @state.threadLabelComponents
|
|
|
|
LabelComponent = label.view
|
|
|
|
<LabelComponent thread={thread} />
|
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
lastMessageType = (thread) ->
|
2015-03-28 09:23:34 +08:00
|
|
|
myEmail = NamespaceStore.current()?.emailAddress
|
2015-04-21 06:59:43 +08:00
|
|
|
|
2015-04-07 02:46:20 +08:00
|
|
|
msgs = thread.metadata
|
2015-04-21 06:59:43 +08:00
|
|
|
return 'unknown' unless msgs and msgs instanceof Array
|
|
|
|
|
|
|
|
msgs = _.filter msgs, (m) -> m.isSaved()
|
2015-03-26 03:41:48 +08:00
|
|
|
msg = msgs[msgs.length - 1]
|
2015-04-21 06:59:43 +08:00
|
|
|
return 'unknown' unless msgs.length > 0
|
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
if thread.unread
|
|
|
|
return 'unread'
|
2015-04-21 06:59:43 +08:00
|
|
|
else if msg.from[0].email isnt myEmail or msgs.length is 1
|
2015-03-26 03:41:48 +08:00
|
|
|
return 'other'
|
|
|
|
else if Utils.isForwardedMessage(msg)
|
|
|
|
return 'forwarded'
|
2015-03-10 09:25:53 +08:00
|
|
|
else
|
2015-03-26 03:41:48 +08:00
|
|
|
return 'replied'
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
c1 = new ListTabular.Column
|
2015-03-10 09:25:53 +08:00
|
|
|
name: "★"
|
|
|
|
resolver: (thread) ->
|
2015-03-26 03:41:48 +08:00
|
|
|
<div className="thread-icon thread-icon-#{lastMessageType(thread)}"></div>
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-03-26 03:41:48 +08:00
|
|
|
c2 = new ListTabular.Column
|
2015-03-10 09:25:53 +08:00
|
|
|
name: "Name"
|
2015-03-26 09:22:52 +08:00
|
|
|
width: 200
|
2015-03-26 04:01:22 +08:00
|
|
|
resolver: (thread) ->
|
2015-03-26 03:41:48 +08:00
|
|
|
<ThreadListParticipants thread={thread} />
|
2015-03-10 09:25:53 +08:00
|
|
|
|
|
|
|
c3 = new ListTabular.Column
|
2015-03-26 03:41:48 +08:00
|
|
|
name: "Message"
|
2015-03-10 09:25:53 +08:00
|
|
|
flex: 4
|
|
|
|
resolver: (thread) ->
|
2015-03-26 03:41:48 +08:00
|
|
|
attachments = []
|
|
|
|
if thread.hasTagId('attachment')
|
|
|
|
attachments = <div className="thread-icon thread-icon-attachment"></div>
|
|
|
|
<span className="details">
|
|
|
|
<span className="subject">{subject(thread.subject)}</span>
|
|
|
|
<span className="snippet">{thread.snippet}</span>
|
|
|
|
{attachments}
|
|
|
|
</span>
|
2015-03-10 09:25:53 +08:00
|
|
|
|
|
|
|
c4 = new ListTabular.Column
|
|
|
|
name: "Date"
|
|
|
|
resolver: (thread) ->
|
|
|
|
<span className="timestamp">{timestamp(thread.lastMessageTimestamp)}</span>
|
|
|
|
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
@columns = [c1, c2, c3, c4]
|
2015-04-09 10:25:00 +08:00
|
|
|
@commands =
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
'core:remove-item': @_onArchive
|
2015-04-09 10:25:00 +08:00
|
|
|
'core:remove-and-previous': -> Actions.archiveAndPrevious()
|
|
|
|
'core:remove-and-next': -> Actions.archiveAndNext()
|
|
|
|
'application:reply': @_onReply
|
|
|
|
'application:reply-all': @_onReplyAll
|
|
|
|
'application:forward': @_onForward
|
2015-04-23 07:41:29 +08:00
|
|
|
@itemPropsProvider = (item) ->
|
|
|
|
className: React.addons.classSet
|
2015-04-09 10:25:00 +08:00
|
|
|
'unread': item.isUnread()
|
|
|
|
|
|
|
|
render: ->
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
<MultiselectList
|
2015-04-09 10:25:00 +08:00
|
|
|
dataStore={ThreadListStore}
|
|
|
|
columns={@columns}
|
|
|
|
commands={@commands}
|
2015-04-23 07:41:29 +08:00
|
|
|
itemPropsProvider={@itemPropsProvider}
|
2015-04-09 10:25:00 +08:00
|
|
|
className="thread-list"
|
|
|
|
collection="thread" />
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
# Additional Commands
|
2015-03-21 01:23:50 +08:00
|
|
|
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
_onArchive: ->
|
|
|
|
if @_viewingFocusedThread() or ThreadListStore.view().selection.count() is 0
|
|
|
|
Actions.archive()
|
|
|
|
else
|
|
|
|
Actions.archiveSelection()
|
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
_onReply: ({focusedId}) ->
|
|
|
|
return unless focusedId? and @_viewingFocusedThread()
|
|
|
|
Actions.composeReply(threadId: focusedId)
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
_onReplyAll: ({focusedId}) ->
|
|
|
|
return unless focusedId? and @_viewingFocusedThread()
|
|
|
|
Actions.composeReplyAll(threadId: focusedId)
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
_onForward: ({focusedId}) ->
|
|
|
|
return unless focusedId? and @_viewingFocusedThread()
|
|
|
|
Actions.composeForward(threadId: focusedId)
|
2015-03-10 09:25:53 +08:00
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
# Helpers
|
2015-03-26 02:17:57 +08:00
|
|
|
|
2015-04-09 10:25:00 +08:00
|
|
|
_viewingFocusedThread: ->
|
refactor(*): Thread list fixes, flexible workspace store, multiple root sheets
Summary:
Remember to remove all the event listeners added to email frame
New files tab, queryable filename, not attribute
Rename ThreadSelectionBar to RootSelectionBar to go with RootCenterComponent, make it appear for draft selection and file selection as well
Initial file list and file list store, File Location
Remove unnecessary shouldComponentUpdate
Always track whether new requests have happened since ours to prevent out of order triggers
Always scroll to the current [focused/keyboard-cursor] in lists
So goodbye to the trash tag
Only scroll to current item if focus or keyboard has moved
Show message snippet in notification if no subject line
Make the RootSelectionBar pull items from Component Registry
New Archive button (prettier than the other one)
Refactor event additions to iframe so iframe can be used for file display also
Thread List is no longer the uber root package - drafts and files moved to separate packages
WorkspaceStore now allows packages to register sheets, "view" concept replaced with "root sheet" concept, "mode" may not be observed by all sheets, and is now called "preferred mode"
Don't animate transitions between two root sheets
Mode switch is only visible on root sheets that support multiple modes
Account sidebar now shows "Views" that have registered themselves: drafts and files for now
Model Selection Bar is now a component, just like ModelList. Meant to be in the toolbar above a Model List
Misc supporting changes
New files package which registers it's views and components
Rename files package to `file-list`
Move checkmark column down into model list
Don't throw exception if shift-down arrow and nothing selected
Takes a long time on login to fetch first page of threads, make pages smaller
Displaynames, spec fixes
Test Plan: Run tests
Reviewers: evan
Reviewed By: evan
Differential Revision: https://review.inboxapp.com/D1412
2015-04-11 05:33:05 +08:00
|
|
|
if WorkspaceStore.layoutMode() is "list"
|
|
|
|
WorkspaceStore.topSheet() is WorkspaceStore.Sheet.Thread
|
2015-04-01 08:19:17 +08:00
|
|
|
else
|
|
|
|
true
|