mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-23 00:36:50 +08:00
68343ec472
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
94 lines
2.3 KiB
CoffeeScript
94 lines
2.3 KiB
CoffeeScript
React = require "react/addons"
|
|
classNames = require 'classnames'
|
|
ThreadListStore = require './thread-list-store'
|
|
{RetinaImg} = require 'ui-components'
|
|
{Actions, AddRemoveTagsTask, FocusedContentStore} = require "inbox-exports"
|
|
|
|
ThreadBulkArchiveButton = React.createClass
|
|
displayName: 'ThreadBulkArchiveButton'
|
|
|
|
propTypes:
|
|
selection: React.PropTypes.object.isRequired
|
|
|
|
render: ->
|
|
<button style={order:-100}
|
|
className="btn btn-toolbar"
|
|
data-tooltip="Archive"
|
|
onClick={@_onArchive}>
|
|
<RetinaImg name="toolbar-archive.png" />
|
|
</button>
|
|
|
|
_onArchive: ->
|
|
Actions.archiveSelection()
|
|
|
|
|
|
ThreadNavButtonMixin =
|
|
getInitialState: ->
|
|
@_getStateFromStores()
|
|
|
|
componentDidMount: ->
|
|
@_unsubscribe = ThreadListStore.listen @_onStoreChange
|
|
@_unsubscribe_focus = FocusedContentStore.listen @_onStoreChange
|
|
|
|
isFirstThread: ->
|
|
selectedId = FocusedContentStore.focusedId('thread')
|
|
ThreadListStore.view().get(0)?.id is selectedId
|
|
|
|
isLastThread: ->
|
|
selectedId = FocusedContentStore.focusedId('thread')
|
|
|
|
lastIndex = ThreadListStore.view().count() - 1
|
|
ThreadListStore.view().get(lastIndex)?.id is selectedId
|
|
|
|
componentWillUnmount: ->
|
|
@_unsubscribe()
|
|
@_unsubscribe_focus()
|
|
|
|
_onStoreChange: ->
|
|
@setState @_getStateFromStores()
|
|
|
|
|
|
DownButton = React.createClass
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
render: ->
|
|
<div className={@_classSet()} onClick={@_onClick}>
|
|
<RetinaImg name="toolbar-down-arrow.png"/>
|
|
</div>
|
|
|
|
_classSet: ->
|
|
classNames
|
|
"message-toolbar-arrow": true
|
|
"down": true
|
|
"disabled": @state.disabled
|
|
|
|
_onClick: ->
|
|
return if @state.disabled
|
|
atom.commands.dispatch(document.body, 'core:next-item')
|
|
|
|
_getStateFromStores: ->
|
|
disabled: @isLastThread()
|
|
|
|
UpButton = React.createClass
|
|
mixins: [ThreadNavButtonMixin]
|
|
|
|
render: ->
|
|
<div className={@_classSet()} onClick={@_onClick}>
|
|
<RetinaImg name="toolbar-up-arrow.png"/>
|
|
</div>
|
|
|
|
_classSet: ->
|
|
classNames
|
|
"message-toolbar-arrow": true
|
|
"up": true
|
|
"disabled": @state.disabled
|
|
|
|
_onClick: ->
|
|
return if @state.disabled
|
|
atom.commands.dispatch(document.body, 'core:previous-item')
|
|
|
|
_getStateFromStores: ->
|
|
disabled: @isFirstThread()
|
|
|
|
module.exports = {DownButton, UpButton, ThreadBulkArchiveButton}
|