mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
886328ff7a
Great breakdown of React changes here: https://github.com/facebook/react/blob/master/CHANGELOG.md#0140-october-7-2015 Due to deprecation warnings, I don't think this will break third-party extensions unless they were doing really bad things.
47 lines
1.4 KiB
CoffeeScript
47 lines
1.4 KiB
CoffeeScript
classNames = require 'classnames'
|
|
React = require 'react'
|
|
|
|
class DeveloperBarCurlItem extends React.Component
|
|
@displayName: 'DeveloperBarCurlItem'
|
|
|
|
render: =>
|
|
classes = classNames
|
|
"item": true
|
|
"error-code": @_isError()
|
|
<div className={classes}>
|
|
<div className="code">{@props.item.statusCode}{@_errorMessage()}</div>
|
|
<span className="timestamp">{@props.item.startMoment.format("HH:mm:ss")} </span>
|
|
<a onClick={@_onRunCommand}>Run</a>
|
|
<a onClick={@_onCopyCommand}>Copy</a>
|
|
{@props.item.command}
|
|
</div>
|
|
|
|
shouldComponentUpdate: (nextProps) =>
|
|
return @props.item isnt nextProps.item
|
|
|
|
_onCopyCommand: =>
|
|
clipboard = require('clipboard')
|
|
clipboard.writeText(@props.item.command)
|
|
|
|
_isError: ->
|
|
return false if @props.item.statusCode is "pending"
|
|
return not (parseInt(@props.item.statusCode) <= 399)
|
|
|
|
_errorMessage: ->
|
|
if (@props.item.errorMessage ? "").length > 0
|
|
return " | #{@props.item.errorMessage}"
|
|
else
|
|
return ""
|
|
|
|
_onRunCommand: =>
|
|
curlFile = "#{NylasEnv.getConfigDirPath()}/curl.command"
|
|
fs = require 'fs-plus'
|
|
if fs.existsSync(curlFile)
|
|
fs.unlinkSync(curlFile)
|
|
fs.writeFileSync(curlFile, @props.item.command)
|
|
fs.chmodSync(curlFile, '777')
|
|
{shell} = require 'electron'
|
|
shell.openItem(curlFile)
|
|
|
|
|
|
module.exports = DeveloperBarCurlItem
|