Mailspring/internal_packages/thread-list/lib/thread-list-quick-actions.cjsx
Ben Gotow 237bad59d8 feat(unread/spam): New items in the sidebar for unread and spam
Summary:
Adds a new unified "Spam" folder and a unified "Unread" view,
which shows all the messages in your inbox which are unread.

Test Plan: Run tests

Reviewers: evan, juan

Reviewed By: juan

Differential Revision: https://phab.nylas.com/D2901
2016-04-19 11:32:33 -07:00

63 lines
1.6 KiB
CoffeeScript

React = require 'react'
{Actions,
CategoryStore,
TaskFactory,
AccountStore,
FocusedPerspectiveStore} = require 'nylas-exports'
class ThreadArchiveQuickAction extends React.Component
@displayName: 'ThreadArchiveQuickAction'
@propTypes:
thread: React.PropTypes.object
render: =>
allowed = FocusedPerspectiveStore.current().canArchiveThreads([@props.thread])
return <span /> unless allowed
<div
key="archive"
title="Archive"
style={{ order: 100 }}
className="btn action action-archive"
onClick={@_onArchive} />
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_onArchive: (event) =>
tasks = TaskFactory.tasksForArchiving
threads: [@props.thread]
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: =>
allowed = FocusedPerspectiveStore.current().canMoveThreadsTo([@props.thread], 'trash')
return <span /> unless allowed
<div
key="remove"
title="Trash"
style={{ order: 110 }}
className='btn action action-trash'
onClick={@_onRemove} />
shouldComponentUpdate: (newProps, newState) ->
newProps.thread.id isnt @props?.thread.id
_onRemove: (event) =>
tasks = TaskFactory.tasksForMovingToTrash
threads: [@props.thread]
Actions.queueTasks(tasks)
# Don't trigger the thread row click
event.stopPropagation()
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }