2015-02-25 08:19:47 +08:00
|
|
|
React = require 'react/addons'
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
class ActivityBarCurlItem extends React.Component
|
|
|
|
@displayName: 'ActivityBarCurlItem'
|
2015-02-25 08:19:47 +08:00
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
render: =>
|
2015-02-25 08:19:47 +08:00
|
|
|
<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>
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onCopyCommand: =>
|
2015-02-25 08:19:47 +08:00
|
|
|
clipboard = require('clipboard')
|
|
|
|
clipboard.writeText(@props.item.command)
|
|
|
|
|
2015-05-01 04:08:29 +08:00
|
|
|
_onRunCommand: =>
|
2015-02-25 08:19:47 +08:00
|
|
|
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)
|
2015-05-01 04:08:29 +08:00
|
|
|
|
|
|
|
|
|
|
|
module.exports = ActivityBarCurlItem
|