2015-10-22 01:38:00 +08:00
|
|
|
{RetinaImg} = require 'nylas-component-kit'
|
|
|
|
{Actions,
|
2015-12-16 03:03:35 +08:00
|
|
|
React,
|
2015-10-22 01:38:00 +08:00
|
|
|
TaskFactory,
|
|
|
|
DOMUtils,
|
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
|
|
|
|
|
|
|
class ThreadArchiveButton extends React.Component
|
|
|
|
@displayName: "ThreadArchiveButton"
|
|
|
|
@containerRequired: false
|
|
|
|
|
|
|
|
@propTypes:
|
|
|
|
thread: React.PropTypes.object.isRequired
|
|
|
|
|
|
|
|
render: =>
|
2016-03-08 10:13:53 +08:00
|
|
|
canArchiveThreads = FocusedPerspectiveStore.current().canArchiveThreads([@props.thread])
|
|
|
|
return <span /> unless canArchiveThreads
|
2015-10-22 01:38:00 +08:00
|
|
|
|
|
|
|
<button className="btn btn-toolbar btn-archive"
|
|
|
|
style={order: -107}
|
2015-10-22 02:03:27 +08:00
|
|
|
title="Archive"
|
2015-10-22 01:38:00 +08:00
|
|
|
onClick={@_onArchive}>
|
|
|
|
<RetinaImg name="toolbar-archive.png" mode={RetinaImg.Mode.ContentIsMask}/>
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onArchive: (e) =>
|
|
|
|
return unless DOMUtils.nodeIsVisible(e.currentTarget)
|
2017-06-24 07:09:29 +08:00
|
|
|
tasks = TaskFactory.tasksForArchiving
|
|
|
|
threads: [@props.thread]
|
|
|
|
source: "Toolbar Button: Message List"
|
|
|
|
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 = ThreadArchiveButton
|