2015-10-08 04:55:54 +08:00
|
|
|
{Utils,
|
|
|
|
React,
|
|
|
|
FocusedContactsStore,
|
|
|
|
AccountStore,
|
|
|
|
Actions} = require 'nylas-exports'
|
|
|
|
{RetinaImg} = require 'nylas-component-kit'
|
2015-10-10 07:12:48 +08:00
|
|
|
FeedbackActions = require './feedback-actions'
|
2015-10-08 04:55:54 +08:00
|
|
|
|
|
|
|
class FeedbackButton extends React.Component
|
|
|
|
@displayName: 'FeedbackButton'
|
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = {newMessages: false}
|
|
|
|
|
|
|
|
componentDidMount: =>
|
2015-10-10 07:12:48 +08:00
|
|
|
@_unsubs = []
|
|
|
|
@_unsubs.push Actions.sendFeedback.listen(@_onSendFeedback)
|
|
|
|
@_unsubs.push FeedbackActions.feedbackAvailable.listen(@_onFeedbackAvailable)
|
2015-10-08 04:55:54 +08:00
|
|
|
|
|
|
|
componentWillUnmount: =>
|
2015-10-10 07:12:48 +08:00
|
|
|
unsub() for unsub in @_unsubs
|
2015-10-08 04:55:54 +08:00
|
|
|
|
|
|
|
render: =>
|
2015-10-22 02:03:27 +08:00
|
|
|
<div style={position:"absolute",height:0} title="Help & Feedback">
|
2015-10-08 04:55:54 +08:00
|
|
|
<div className={@_getClassName()} onClick={@_onSendFeedback}>?</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
_getClassName: =>
|
|
|
|
return "btn-feedback" + if @state.newMessages then " newmsg" else ""
|
|
|
|
|
2015-10-10 07:12:48 +08:00
|
|
|
_onFeedbackAvailable: =>
|
|
|
|
@setState(newMessages: true)
|
|
|
|
|
2015-10-08 04:55:54 +08:00
|
|
|
_onSendFeedback: =>
|
2015-11-12 02:25:11 +08:00
|
|
|
return if NylasEnv.inSpecMode()
|
2015-10-08 04:55:54 +08:00
|
|
|
|
|
|
|
Screen = require('remote').require('screen')
|
|
|
|
qs = require 'querystring'
|
|
|
|
|
2015-11-10 04:14:33 +08:00
|
|
|
account = AccountStore.current()
|
|
|
|
params = qs.stringify({
|
|
|
|
name: account.name
|
|
|
|
email: account.emailAddress
|
|
|
|
accountId: account.id
|
|
|
|
accountProvider: account.provider
|
|
|
|
platform: process.platform
|
|
|
|
provider: account.displayProvider()
|
|
|
|
organizational_unit: account.organizationUnit
|
2015-11-12 02:25:11 +08:00
|
|
|
version: NylasEnv.getVersion()
|
2015-11-10 04:14:33 +08:00
|
|
|
})
|
|
|
|
|
2015-11-12 02:25:11 +08:00
|
|
|
parentBounds = NylasEnv.getCurrentWindow().getBounds()
|
2015-11-10 04:14:33 +08:00
|
|
|
parentScreen = Screen.getDisplayMatching(parentBounds)
|
|
|
|
|
|
|
|
width = 376
|
|
|
|
height = Math.min(550, parentBounds.height)
|
|
|
|
x = Math.min(parentScreen.workAreaSize.width - width, Math.max(0, parentBounds.x + parentBounds.width - 36 - width / 2))
|
|
|
|
y = Math.max(0, (parentBounds.y + parentBounds.height) - height - 60)
|
|
|
|
|
2015-11-24 14:09:17 +08:00
|
|
|
require('electron').ipcRenderer.send('show-feedback-window', { x, y, width, height, params })
|
2015-11-10 04:14:33 +08:00
|
|
|
setTimeout =>
|
|
|
|
@setState(newMessages: false)
|
|
|
|
, 250
|
2015-10-08 04:55:54 +08:00
|
|
|
|
|
|
|
module.exports = FeedbackButton
|