React = require 'react' {DatabaseStore, NamespaceStore, TaskStore, Actions, Contact, Message} = require 'inbox-exports' ActivityBarStore = require './activity-bar-store' ActivityBarCurlItem = React.createClass render: ->
{@props.item.statusCode}
Run Copy {@props.item.command}
_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 = ActivityBar = React.createClass getInitialState: -> @_getStateFromStores() componentDidMount: -> @task_store_unsubscribe = TaskStore.listen @_onChange @activity_store_unsubscribe = ActivityBarStore.listen @_onChange componentWillUnmount: -> @task_store_unsubscribe() if @task_store_unsubscribe @activity_store_unsubscribe() if @activity_store_unsubscribe render: -> expandedDiv =
if @state.expandedSection == 'curl' curlDivs = @state.curlHistory.map (item) -> expandedDiv =
{curlDivs}
if @state.expandedSection == 'queue' queueDivs = @state.queuePending.map (task) ->
{task.constructor.name}: {JSON.stringify(task.toJSON())}
queuePendingDivs = @state.queue.map (task) ->
{task.constructor.name}: {JSON.stringify(task.toJSON())}
expandedDiv =
Reset Queue
Restart Queue
{queueDivs}{queuePendingDivs}
Queue Length: {@state.queue?.length + @state.queuePending?.length}
Long Polling: {@state.longPollState}
Requests: {@state.curlHistory.length}
Feedback
{expandedDiv}
_onChange: -> @setState(@_getStateFromStores()) _onRestartQueue: -> Actions.restartTaskQueue() _onResetQueue: -> Actions.resetTaskQueue() _onCloseSection: -> Actions.developerPanelSelectSection('') _onExpandCurlSection: -> Actions.developerPanelSelectSection('curl') _onExpandQueueSection: -> Actions.developerPanelSelectSection('queue') _onFeedback: -> user = NamespaceStore.current().name debugData = JSON.stringify({ queries: @state.curlHistory, queue: @state.queue, queue_pending: @state.queuePending }, null, '\t') draft = new Message from: [NamespaceStore.current().me()] to: [ new Contact name: "Nilas Team" email: "feedback@nilas.com" ] date: (new Date) draft: true subject: "Feedback" namespaceId: NamespaceStore.current().id body: """

Hi, Edgehill team!

I have some feedback for you.

What happened

Impact

Feedback

Environment
I'm using Edgehill #{atom.getVersion()} and my platform is #{process.platform}-#{process.arch}.

--

#{user}


-- Extra Debugging Data --

#{debugData}

""" DatabaseStore.persistModel(draft).then -> DatabaseStore.localIdForModel(draft).then (localId) -> Actions.composePopoutDraft(localId) _getStateFromStores: -> expandedSection: ActivityBarStore.expandedSection() curlHistory: ActivityBarStore.curlHistory() queue:TaskStore.queuedTasks() queuePending: TaskStore.pendingTasks() queueState: if TaskStore.isPaused() then "paused" else "running" longPollState: ActivityBarStore.longPollState()