mirror of
https://github.com/Foundry376/Mailspring.git
synced 2024-11-14 05:41:05 +08:00
e4a57aaf12
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
33 lines
950 B
CoffeeScript
33 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
|