2015-04-01 07:32:14 +08:00
|
|
|
_ = require 'underscore-plus'
|
2015-03-07 04:03:32 +08:00
|
|
|
React = require 'react'
|
2015-04-09 10:25:00 +08:00
|
|
|
{Actions, Utils, FocusedContentStore, WorkspaceStore} = require 'inbox-exports'
|
2015-03-07 04:03:32 +08:00
|
|
|
{RetinaImg} = require 'ui-components'
|
|
|
|
|
|
|
|
# Note: These always have a thread, but only sometimes get a
|
|
|
|
# message, depending on where in the UI they are being displayed.
|
|
|
|
|
|
|
|
ReplyButton = React.createClass
|
|
|
|
render: ->
|
2015-03-13 06:09:10 +08:00
|
|
|
<button className="btn btn-toolbar"
|
|
|
|
data-tooltip="Reply"
|
|
|
|
onClick={@_onReply}>
|
2015-03-07 04:03:32 +08:00
|
|
|
<RetinaImg name="toolbar-reply.png" />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onReply: (e) ->
|
2015-03-13 09:47:01 +08:00
|
|
|
return unless Utils.nodeIsVisible(e.currentTarget)
|
2015-04-09 10:25:00 +08:00
|
|
|
Actions.composeReply(threadId: FocusedContentStore.focusedId('thread'))
|
2015-03-07 04:03:32 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
ReplyAllButton = React.createClass
|
|
|
|
render: ->
|
2015-03-13 06:09:10 +08:00
|
|
|
<button className="btn btn-toolbar"
|
|
|
|
data-tooltip="Reply All"
|
|
|
|
onClick={@_onReplyAll}>
|
2015-03-07 04:03:32 +08:00
|
|
|
<RetinaImg name="toolbar-reply-all.png" />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onReplyAll: (e) ->
|
2015-03-13 09:47:01 +08:00
|
|
|
return unless Utils.nodeIsVisible(e.currentTarget)
|
2015-04-09 10:25:00 +08:00
|
|
|
Actions.composeReplyAll(threadId: FocusedContentStore.focusedId('thread'))
|
2015-03-07 04:03:32 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
ForwardButton = React.createClass
|
|
|
|
render: ->
|
2015-03-13 06:09:10 +08:00
|
|
|
<button className="btn btn-toolbar"
|
|
|
|
data-tooltip="Forward"
|
|
|
|
onClick={@_onForward}>
|
2015-03-07 04:03:32 +08:00
|
|
|
<RetinaImg name="toolbar-forward.png" />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onForward: (e) ->
|
2015-03-13 09:47:01 +08:00
|
|
|
return unless Utils.nodeIsVisible(e.currentTarget)
|
2015-04-09 10:25:00 +08:00
|
|
|
Actions.composeForward(threadId: FocusedContentStore.focusedId('thread'))
|
2015-03-07 04:03:32 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
ArchiveButton = React.createClass
|
|
|
|
render: ->
|
2015-03-26 02:17:57 +08:00
|
|
|
<button className="btn btn-toolbar btn-archive"
|
2015-03-13 06:09:10 +08:00
|
|
|
data-tooltip="Archive"
|
|
|
|
onClick={@_onArchive}>
|
2015-03-07 04:03:32 +08:00
|
|
|
<RetinaImg name="toolbar-archive.png" />
|
|
|
|
</button>
|
|
|
|
|
|
|
|
_onArchive: (e) ->
|
2015-03-13 09:47:01 +08:00
|
|
|
return unless Utils.nodeIsVisible(e.currentTarget)
|
2015-03-26 02:17:57 +08:00
|
|
|
if WorkspaceStore.selectedLayoutMode() is "list"
|
|
|
|
Actions.archiveCurrentThread()
|
|
|
|
else if WorkspaceStore.selectedLayoutMode() is "split"
|
|
|
|
Actions.archiveAndNext()
|
2015-03-07 04:03:32 +08:00
|
|
|
e.stopPropagation()
|
|
|
|
|
|
|
|
|
2015-03-26 02:17:57 +08:00
|
|
|
module.exports =
|
|
|
|
MessageToolbarItems = React.createClass
|
2015-03-07 04:03:32 +08:00
|
|
|
getInitialState: ->
|
2015-04-09 10:25:00 +08:00
|
|
|
threadIsSelected: FocusedContentStore.focusedId('thread')?
|
2015-03-07 04:03:32 +08:00
|
|
|
|
|
|
|
render: ->
|
|
|
|
classes = React.addons.classSet
|
|
|
|
"message-toolbar-items": true
|
|
|
|
"hidden": !@state.threadIsSelected
|
|
|
|
|
|
|
|
<div className={classes}>
|
2015-03-26 02:17:57 +08:00
|
|
|
<ArchiveButton ref="archiveButton" />
|
2015-03-07 04:03:32 +08:00
|
|
|
</div>
|
|
|
|
|
|
|
|
componentDidMount: ->
|
|
|
|
@_unsubscribers = []
|
2015-04-09 10:25:00 +08:00
|
|
|
@_unsubscribers.push FocusedContentStore.listen @_onChange
|
2015-03-07 04:03:32 +08:00
|
|
|
|
|
|
|
componentWillUnmount: ->
|
|
|
|
unsubscribe() for unsubscribe in @_unsubscribers
|
|
|
|
|
2015-04-01 07:32:14 +08:00
|
|
|
_onChange: -> _.defer =>
|
|
|
|
return unless @isMounted()
|
2015-03-07 04:03:32 +08:00
|
|
|
@setState
|
2015-04-09 10:25:00 +08:00
|
|
|
threadIsSelected: FocusedContentStore.focusedId('thread')?
|