2015-10-22 01:38:00 +08:00
|
|
|
_ = require 'underscore'
|
|
|
|
React = require 'react'
|
|
|
|
{Actions,
|
|
|
|
DOMUtils,
|
|
|
|
TaskFactory,
|
2016-03-08 10:13:53 +08:00
|
|
|
AccountStore,
|
2016-01-09 06:58:31 +08:00
|
|
|
FocusedPerspectiveStore} = require 'nylas-exports'
|
2015-10-22 01:38:00 +08:00
|
|
|
{RetinaImg} = require 'nylas-component-kit'
|
|
|
|
|
|
|
|
class ThreadTrashButton extends React.Component
|
|
|
|
@displayName: "ThreadTrashButton"
|
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object.isRequired
|
|
|
|
|
|
|
|
render: =>
|
2016-04-20 02:32:33 +08:00
|
|
|
allowed = FocusedPerspectiveStore.current().canMoveThreadsTo([@props.thread], 'trash')
|
|
|
|
return <span /> unless allowed
|
2015-10-22 01:38:00 +08:00
|
|
|
|
|
|
|
<button className="btn btn-toolbar"
|
|
|
|
style={order: -106}
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Move to Trash"
|
2015-10-22 01:38:00 +08:00
|
|
|
onClick={@_onRemove}>
|
|
|
|
<RetinaImg name="toolbar-trash.png" mode={RetinaImg.Mode.ContentIsMask}/>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onRemove: (e) =>
|
|
|
|
return unless DOMUtils.nodeIsVisible(e.currentTarget)
|
2017-06-24 07:11:53 +08:00
|
|
|
tasks = TaskFactory.tasksForMovingToTrash
|
|
|
|
source: "Toolbar Button: Thread List"
|
|
|
|
threads: [@props.thread]
|
|
|
|
Actions.queueTasks(tasks)
|
2015-10-24 06:21:37 +08:00
|
|
|
Actions.popSheet()
|
2015-10-22 01:38:00 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = ThreadTrashButton
|