Mailspring/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx

66 lines
1.9 KiB
Plaintext
Raw Normal View History

React = require 'react'
{Actions,
CategoryStore,
TaskFactory,
FocusedPerspectiveStore} = require 'nylas-exports'
class ThreadArchiveQuickAction extends React.Component
@displayName: 'ThreadArchiveQuickAction'
@propTypes:
thread: React.PropTypes.object
render: =>
mailboxPerspective = FocusedPerspectiveStore.current()
archive = null
if mailboxPerspective?.canArchiveThreads()
archive = <div key="archive"
title="Archive"
2016-01-07 03:22:41 +08:00
style={{ order: 100 }}
className="btn action action-archive"
onClick={@_onArchive}></div>
return archive
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_onArchive: (event) =>
tasks = TaskFactory.tasksForArchiving
threads: [@props.thread]
2016-01-15 07:04:17 +08:00
fromPerspective: FocusedPerspectiveStore.current()
Actions.queueTasks(tasks)
# Don't trigger the thread row click
event.stopPropagation()
class ThreadTrashQuickAction extends React.Component
@displayName: 'ThreadTrashQuickAction'
@propTypes:
thread: React.PropTypes.object
render: =>
mailboxPerspective = FocusedPerspectiveStore.current()
trash = null
if mailboxPerspective?.canTrashThreads()
trash = <div key="remove"
title="Trash"
2016-01-07 03:22:41 +08:00
style={{ order: 110 }}
className='btn action action-trash'
onClick={@_onRemove}></div>
return trash
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_onRemove: (event) =>
tasks = TaskFactory.tasksForMovingToTrash
threads: [@props.thread]
2016-01-15 07:04:17 +08:00
fromPerspective: FocusedPerspectiveStore.current()
Actions.queueTasks(tasks)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }