2015-06-12 09:38:57 +08:00
|
|
|
React = require 'react'
|
|
|
|
{Actions,
|
2015-10-22 01:38:00 +08:00
|
|
|
CategoryStore,
|
|
|
|
TaskFactory,
|
2016-03-08 10:13:53 +08:00
|
|
|
AccountStore,
|
2016-01-09 06:58:31 +08:00
|
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
2015-06-12 09:38:57 +08:00
|
|
|
|
2016-01-04 09:03:52 +08:00
|
|
|
class ThreadArchiveQuickAction extends React.Component
|
|
|
|
@displayName: 'ThreadArchiveQuickAction'
|
2015-06-12 09:38:57 +08:00
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object
|
|
|
|
|
|
|
|
render: =>
|
2016-03-08 10:13:53 +08:00
|
|
|
canArchiveThreads = FocusedPerspectiveStore.current().canArchiveThreads([@props.thread])
|
|
|
|
return <span /> unless canArchiveThreads
|
2015-06-12 09:38:57 +08:00
|
|
|
|
2016-03-08 10:13:53 +08:00
|
|
|
<div
|
|
|
|
key="archive"
|
|
|
|
title="Archive"
|
|
|
|
style={{ order: 100 }}
|
|
|
|
className="btn action action-archive"
|
|
|
|
onClick={@_onArchive} />
|
2015-06-12 09:38:57 +08:00
|
|
|
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
|
2015-10-22 01:38:00 +08:00
|
|
|
_onArchive: (event) =>
|
2016-01-22 05:46:04 +08:00
|
|
|
tasks = TaskFactory.tasksForArchiving
|
2015-10-22 01:38:00 +08:00
|
|
|
threads: [@props.thread]
|
2016-01-22 05:46:04 +08:00
|
|
|
Actions.queueTasks(tasks)
|
2015-10-22 01:38:00 +08:00
|
|
|
|
|
|
|
# Don't trigger the thread row click
|
|
|
|
event.stopPropagation()
|
|
|
|
|
2016-01-04 09:03:52 +08:00
|
|
|
class ThreadTrashQuickAction extends React.Component
|
|
|
|
@displayName: 'ThreadTrashQuickAction'
|
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object
|
|
|
|
|
|
|
|
render: =>
|
2016-03-08 10:13:53 +08:00
|
|
|
canTrashThreads = FocusedPerspectiveStore.current().canTrashThreads([@props.thread])
|
|
|
|
return <span /> unless canTrashThreads
|
2016-01-04 09:03:52 +08:00
|
|
|
|
2016-03-08 10:13:53 +08:00
|
|
|
<div
|
|
|
|
key="remove"
|
|
|
|
title="Trash"
|
|
|
|
style={{ order: 110 }}
|
|
|
|
className='btn action action-trash'
|
|
|
|
onClick={@_onRemove} />
|
2016-01-04 09:03:52 +08:00
|
|
|
|
|
|
|
shouldComponentUpdate: (newProps, newState) ->
|
|
|
|
newProps.thread.id isnt @props?.thread.id
|
|
|
|
|
2015-10-01 10:51:48 +08:00
|
|
|
_onRemove: (event) =>
|
2016-01-22 05:46:04 +08:00
|
|
|
tasks = TaskFactory.tasksForMovingToTrash
|
2015-10-22 01:38:00 +08:00
|
|
|
threads: [@props.thread]
|
2016-01-22 05:46:04 +08:00
|
|
|
Actions.queueTasks(tasks)
|
2015-06-12 09:38:57 +08:00
|
|
|
|
|
|
|
# Don't trigger the thread row click
|
|
|
|
event.stopPropagation()
|
|
|
|
|
2016-01-04 09:03:52 +08:00
|
|
|
module.exports = { ThreadArchiveQuickAction, ThreadTrashQuickAction }
|