Mailspring/internal_packages/worker-ui/lib/developer-bar-curl-item.cjsx
Evan Morikawa 2aebd5f43b feat(draft): drafts that fail to send throw better errors
Summary: Also enhancements to the developer toolbar

Test Plan: edgehill --test

Reviewers: dillon, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1976
2015-09-03 16:29:33 -07:00

34 lines
1,022 B
CoffeeScript

React = require 'react/addons'
class DeveloperBarCurlItem extends React.Component
@displayName: 'DeveloperBarCurlItem'
render: =>
<div className={"item status-code-#{@props.item.statusCode}"}>
<div className="code">{@props.item.statusCode}</div>
<span className="timestamp">{@props.item.startMoment.format("HH:mm:ss")}&nbsp;&nbsp;</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)
_onRunCommand: =>
curlFile = "#{atom.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 'shell'
shell.openItem(curlFile)
module.exports = DeveloperBarCurlItem