Mailspring/internal_packages/inbox-activity-bar/lib/activity-bar-curl-item.cjsx
Evan Morikawa e3dfbe59be refactor(react): convert to class-based React components
Summary: Fix react upgrade errors

Test Plan: edgehill --test

Reviewers: bengotow

Reviewed By: bengotow

Differential Revision: https://review.inboxapp.com/D1456
2015-04-30 13:08:29 -07:00

30 lines
837 B
CoffeeScript

React = require 'react/addons'
class ActivityBarCurlItem extends React.Component
@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)
module.exports = ActivityBarCurlItem