Mailspring/internal_packages/message-list/lib/message-toolbar-items.cjsx
Ben Gotow 68343ec472 feat(docs): New docs tasks and React 0.13.2
Summary:
This diff moves us up to React 0.13.2 and transitions some of the core React components to the new
syntax based on plain Javascript objects. `setInitialState` is now just code in the constructor,
`getDOMNode(@)` is now `React.findDOMNode(@)`, and `isMounted` is no longer necessary or available.

This diff also adds `RegisteredComponent` to match `RegisteredRegion`. In another diff,
I think we should change the names of these to be `DynamicComponent` and `DynamicComponentSet`.

This diff also includes preliminary API Reference docs for Menu.cjsx and Popover.cjsx. You can build the docs
using `grunt docs` from the build folder. It produces a simple html format now, but it's easy
to customize.

Also we now ignore "Unnecessary fat arrow"

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://review.inboxapp.com/D1437
2015-04-24 11:33:10 -07:00

88 lines
2.5 KiB
CoffeeScript

_ = require 'underscore-plus'
React = require 'react'
classNames = require 'classnames'
{Actions, Utils, FocusedContentStore, WorkspaceStore} = require 'inbox-exports'
{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: ->
<button className="btn btn-toolbar"
data-tooltip="Reply"
onClick={@_onReply}>
<RetinaImg name="toolbar-reply.png" />
</button>
_onReply: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeReply(threadId: FocusedContentStore.focusedId('thread'))
e.stopPropagation()
ReplyAllButton = React.createClass
render: ->
<button className="btn btn-toolbar"
data-tooltip="Reply All"
onClick={@_onReplyAll}>
<RetinaImg name="toolbar-reply-all.png" />
</button>
_onReplyAll: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeReplyAll(threadId: FocusedContentStore.focusedId('thread'))
e.stopPropagation()
ForwardButton = React.createClass
render: ->
<button className="btn btn-toolbar"
data-tooltip="Forward"
onClick={@_onForward}>
<RetinaImg name="toolbar-forward.png" />
</button>
_onForward: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.composeForward(threadId: FocusedContentStore.focusedId('thread'))
e.stopPropagation()
ArchiveButton = React.createClass
render: ->
<button className="btn btn-toolbar btn-archive"
data-tooltip="Archive"
onClick={@_onArchive}>
<RetinaImg name="toolbar-archive.png" />
</button>
_onArchive: (e) ->
return unless Utils.nodeIsVisible(e.currentTarget)
Actions.archive()
e.stopPropagation()
module.exports =
MessageToolbarItems = React.createClass
getInitialState: ->
threadIsSelected: FocusedContentStore.focusedId('thread')?
render: ->
classes = classNames
"message-toolbar-items": true
"hidden": !@state.threadIsSelected
<div className={classes}>
<ArchiveButton ref="archiveButton" />
</div>
componentDidMount: ->
@_unsubscribers = []
@_unsubscribers.push FocusedContentStore.listen @_onChange
componentWillUnmount: ->
unsubscribe() for unsubscribe in @_unsubscribers
_onChange: -> _.defer =>
return unless @isMounted()
@setState
threadIsSelected: FocusedContentStore.focusedId('thread')?