Mailspring/internal_packages/github/lib/view-on-github-button.cjsx
Evan Morikawa ae5429365e feat(github): add GitHub plugin
Summary:
Adding a simple GitHub plugin that shows a button on the thread view.

If we detect the "open in github" links, then we'll show the button on the
thread.

Test Plan: manual

Reviewers: dillon, bengotow

Reviewed By: bengotow

Differential Revision: https://phab.nylas.com/D1959
2015-09-01 11:57:06 -07:00

34 lines
950 B
CoffeeScript

shell = require 'shell'
React = require 'react'
GithubStore = require './github-store'
{RetinaImg} = require 'nylas-component-kit'
class ViewOnGithubButton extends React.Component
@displayName: "ViewOnGithubButton"
@containerRequired: false
constructor: (@props) ->
@state = link: null
componentDidMount: =>
@_unlisten = GithubStore.listen =>
@setState link: GithubStore.link()
@_keymapUnlisten = atom.commands.add 'body', {
'github:open': @_openLink
}
componentWillUnmount: =>
@_unlisten?()
@_keymapUnlisten?.dispose()
render: ->
return null unless @state.link
<button className="btn btn-toolbar"
onClick={@_openLink}
data-tooltip={"Visit Thread on GitHub"}><RetinaImg mode={RetinaImg.Mode.ContentIsMask} url="nylas://github/assets/github@2x.png" /></button>
_openLink: =>
shell.openExternal(@state.link) if @state.link
module.exports = ViewOnGithubButton