mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 21:57:55 +08:00
28 lines
804 B
Text
28 lines
804 B
Text
|
React = require 'react/addons'
|
||
|
|
||
|
module.exports =
|
||
|
ActivityBarCurlItem = React.createClass
|
||
|
displayName: 'ActivityBarCurlItem'
|
||
|
|
||
|
render: ->
|
||
|
<div className={"item status-code-#{@props.item.statusCode}"}>
|
||
|
<div className="code">{@props.item.statusCode}</div>
|
||
|
<a onClick={@_onRunCommand}>Run</a>
|
||
|
<a onClick={@_onCopyCommand}>Copy</a>
|
||
|
{@props.item.command}
|
||
|
</div>
|
||
|
|
||
|
_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)
|