2015-06-12 09:38:57 +08:00
|
|
|
React = require 'react'
|
|
|
|
{Actions,
|
2015-10-22 01:38:00 +08:00
|
|
|
CategoryStore,
|
|
|
|
TaskFactory,
|
2015-10-01 10:51:48 +08:00
|
|
|
FocusedMailViewStore} = require 'nylas-exports'
|
2015-06-12 09:38:57 +08:00
|
|
|
|
|
|
|
class ThreadListQuickActions extends React.Component
|
|
|
|
@displayName: 'ThreadListQuickActions'
|
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object
|
|
|
|
|
|
|
|
render: =>
|
2015-10-22 01:38:00 +08:00
|
|
|
mailViewFilter = FocusedMailViewStore.mailView()
|
|
|
|
archive = null
|
|
|
|
remove = null
|
2015-06-12 09:38:57 +08:00
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
if mailViewFilter?.canArchiveThreads()
|
|
|
|
archive = <div key="archive"
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Archive"
|
2015-10-22 01:38:00 +08:00
|
|
|
className="btn action action-archive"
|
|
|
|
onClick={@_onArchive}></div>
|
|
|
|
|
|
|
|
if mailViewFilter?.canTrashThreads()
|
|
|
|
trash = <div key="remove"
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Trash"
|
2015-10-22 01:38:00 +08:00
|
|
|
className='btn action action-trash'
|
|
|
|
onClick={@_onRemove}></div>
|
2015-09-22 05:15:57 +08:00
|
|
|
|
2015-06-12 09:38:57 +08:00
|
|
|
<div className="inner">
|
2015-10-22 01:38:00 +08:00
|
|
|
{archive}
|
|
|
|
{trash}
|
2015-06-12 09:38:57 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
_onArchive: (event) =>
|
|
|
|
task = TaskFactory.taskForArchiving
|
|
|
|
threads: [@props.thread]
|
|
|
|
fromView: FocusedMailViewStore.mailView()
|
|
|
|
Actions.queueTask(task)
|
|
|
|
|
|
|
|
# Don't trigger the thread row click
|
|
|
|
event.stopPropagation()
|
|
|
|
|
2015-10-01 10:51:48 +08:00
|
|
|
_onRemove: (event) =>
|
2015-10-22 01:38:00 +08:00
|
|
|
task = TaskFactory.taskForMovingToTrash
|
|
|
|
threads: [@props.thread]
|
|
|
|
fromView: FocusedMailViewStore.mailView()
|
|
|
|
Actions.queueTask(task)
|
2015-06-12 09:38:57 +08:00
|
|
|
|
|
|
|
# Don't trigger the thread row click
|
|
|
|
event.stopPropagation()
|
|
|
|
|
|
|
|
module.exports = ThreadListQuickActions
|