_ = require 'underscore-plus' ipc = require 'ipc' React = require 'react/addons' {DatabaseStore, NamespaceStore, TaskQueue, Actions, Contact, Message} = require 'inbox-exports' {ResizableRegion} = require 'ui-components' ActivityBarStore = require './activity-bar-store' ActivityBarTask = require './activity-bar-task' ActivityBarCurlItem = require './activity-bar-curl-item' ActivityBarLongPollItem = require './activity-bar-long-poll-item' ActivityBarClosedHeight = 30 class ActivityBar extends React.Component @displayName: "ActivityBar" @containerRequired: false constructor: (@props) -> @state = _.extend @_getStateFromStores(), height: ActivityBarClosedHeight section: 'curl' filter: '' componentDidMount: => ipc.on 'report-issue', => @_onFeedback() @taskQueueUnsubscribe = TaskQueue.listen @_onChange @activityStoreUnsubscribe = ActivityBarStore.listen @_onChange componentWillUnmount: => @taskQueueUnsubscribe() if @taskQueueUnsubscribe @activityStoreUnsubscribe() if @activityStoreUnsubscribe render: => return
unless @state.visible
{@_caret()}
@_onExpandSection('queue')}> Queue Length: {@state.queue?.length}
@_onExpandSection('long-polling')}>
Long Polling: {@state.longPollState}
@_onExpandSection('curl')}> Requests: {@state.curlHistory.length}
Feedback
Component Regions
{@_sectionContent()}
Clear
_caret: => if @state.height > ActivityBarClosedHeight else _sectionContent: => expandedDiv =
matchingFilter = (item) => return true if @state.filter is '' return JSON.stringify(item).indexOf(@state.filter) >= 0 if @state.section == 'curl' itemDivs = @state.curlHistory.filter(matchingFilter).map (item) -> expandedDiv =
{itemDivs}
else if @state.section == 'long-polling' itemDivs = @state.longPollHistory.filter(matchingFilter).map (item) -> expandedDiv =
{itemDivs}
else if @state.section == 'queue' queue = @state.queue.filter(matchingFilter) queueDivs = for i in [@state.queue.length - 1..0] by -1 task = @state.queue[i] queueCompleted = @state.completed.filter(matchingFilter) queueCompletedDivs = for i in [@state.completed.length - 1..0] by -1 task = @state.completed[i] expandedDiv =
Remove Queued Tasks
{queueDivs}
{queueCompletedDivs}
expandedDiv _onChange: => @setState(@_getStateFromStores()) _onClear: => Actions.clearDeveloperConsole() _onFilter: (ev) => @setState(filter: ev.target.value) _onDequeueAll: => Actions.dequeueAllTasks() _onHide: => @setState height: ActivityBarClosedHeight _onShow: => @setState(height: 200) if @state.height < 100 _onExpandSection: (section) => @setState(section: section) @_onShow() _onToggleRegions: => Actions.toggleComponentRegions() _onFeedback: => user = NamespaceStore.current().name debugData = JSON.stringify({ queries: @state.curlHistory, queue: @state.queue, completed: @state.completed }, null, '\t') # Remove API tokens from URLs included in the debug data # This regex detects ://user:pass@ and removes it. debugData = debugData.replace(/:\/\/(\w)*:(\w)?@/g, '://') 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: => visible: ActivityBarStore.visible() queue: TaskQueue._queue completed: TaskQueue._completed curlHistory: ActivityBarStore.curlHistory() longPollHistory: ActivityBarStore.longPollHistory() longPollState: ActivityBarStore.longPollState() module.exports = ActivityBar