mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-09-24 09:16:07 +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
49 lines
1.5 KiB
CoffeeScript
49 lines
1.5 KiB
CoffeeScript
React = require 'react/addons'
|
|
classNames = require 'classnames'
|
|
|
|
module.exports =
|
|
ActivityBarTask = React.createClass
|
|
displayName: 'ActivityBarTask'
|
|
|
|
getInitialState: ->
|
|
expanded: false
|
|
|
|
render: ->
|
|
<div className={@_classNames()} onClick={=> @setState expanded: not @state.expanded}>
|
|
<div className="task-summary">
|
|
{@_taskSummary()}
|
|
</div>
|
|
<div className="task-details">
|
|
{JSON.stringify(@props.task.toJSON())}
|
|
</div>
|
|
</div>
|
|
|
|
_taskSummary: ->
|
|
qs = @props.task.queueState
|
|
errType = ""
|
|
errCode = ""
|
|
errMessage = ""
|
|
if qs.localError?
|
|
localError = qs.localError
|
|
errType = localError.constructor.name
|
|
errMessage = localError.message ? JSON.stringify(localError)
|
|
else if qs.remoteError?
|
|
remoteError = qs.remoteError
|
|
errType = remoteError.constructor.name
|
|
errCode = remoteError.statusCode ? ""
|
|
errMessage = remoteError.body?.message ? remoteError?.message ? JSON.stringify(remoteError)
|
|
|
|
return "#{@props.task.constructor.name} #{errType} #{errCode} #{errMessage}"
|
|
|
|
_classNames: ->
|
|
qs = @props.task.queueState ? {}
|
|
classNames
|
|
"task": true
|
|
"task-queued": @props.type is "queued"
|
|
"task-completed": @props.type is "completed"
|
|
"task-expanded": @state.expanded
|
|
"task-local-error": qs.localError
|
|
"task-remote-error": qs.remoteError
|
|
"task-is-processing": qs.isProcessing
|
|
"task-success": qs.performedLocal and qs.performedRemote
|