2015-06-03 10:04:21 +08:00
|
|
|
React = require 'react'
|
|
|
|
_ = require "underscore"
|
|
|
|
PackageSet = require './package-set'
|
2015-10-04 09:11:29 +08:00
|
|
|
PackagesStore = require './packages-store'
|
|
|
|
PluginsActions = require './plugins-actions'
|
2015-06-03 10:04:21 +08:00
|
|
|
{Spinner, EventedIFrame, Flexbox} = require 'nylas-component-kit'
|
|
|
|
classNames = require 'classnames'
|
|
|
|
|
|
|
|
class TabInstalled extends React.Component
|
|
|
|
@displayName: 'TabInstalled'
|
|
|
|
|
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @_getStateFromStores()
|
|
|
|
|
|
|
|
render: =>
|
|
|
|
searchEmpty = null
|
|
|
|
if @state.search.length > 0
|
|
|
|
searchEmpty = "No matching packages."
|
|
|
|
|
2015-11-12 02:25:11 +08:00
|
|
|
if NylasEnv.inDevMode()
|
2015-10-04 10:04:19 +08:00
|
|
|
devPackages = @state.packages.dev
|
|
|
|
devEmpty = <span>
|
|
|
|
You don't have any packages installed in ~/.nylas/dev/packages.
|
2015-10-24 06:14:44 +08:00
|
|
|
These plugins are only loaded when you run the app with debug flags
|
2015-10-04 10:04:19 +08:00
|
|
|
enabled (via the Developer menu).<br/><br/>Learn more about building
|
2015-10-24 06:14:44 +08:00
|
|
|
plugins at <a href='https://nylas.com/N1/docs'>https://nylas.com/N1/docs</a>
|
2015-10-04 10:04:19 +08:00
|
|
|
</span>
|
2015-10-24 06:14:44 +08:00
|
|
|
devCTA = <div className="btn btn-large" onClick={@_onCreatePackage}>Create New Plugin...</div>
|
2015-10-04 10:04:19 +08:00
|
|
|
else
|
|
|
|
devPackages = []
|
|
|
|
devEmpty = <span>Run with debug flags enabled to load ~/.nylas/dev/packages.</span>
|
|
|
|
devCTA = <div className="btn btn-large" onClick={@_onEnableDevMode}>Enable Debug Flags</div>
|
|
|
|
|
2015-06-03 10:04:21 +08:00
|
|
|
<div className="installed">
|
|
|
|
<div className="inner">
|
|
|
|
<input
|
|
|
|
type="search"
|
|
|
|
value={@state.search}
|
|
|
|
onChange={@_onSearchChange }
|
2015-10-24 06:14:44 +08:00
|
|
|
placeholder="Search Installed Plugins"/>
|
2015-06-03 10:04:21 +08:00
|
|
|
<PackageSet
|
|
|
|
packages={@state.packages.user}
|
2015-10-04 09:11:29 +08:00
|
|
|
title="Installed"
|
2015-10-24 06:14:44 +08:00
|
|
|
emptyText={searchEmpty ? <span>You don't have any plugins installed in ~/.nylas/packages.</span>} />
|
2015-06-03 10:04:21 +08:00
|
|
|
<PackageSet
|
|
|
|
title="Development"
|
2015-10-04 10:04:19 +08:00
|
|
|
packages={devPackages}
|
|
|
|
emptyText={searchEmpty ? devEmpty} />
|
2015-06-03 10:04:21 +08:00
|
|
|
<div className="new-package">
|
2015-10-04 10:04:19 +08:00
|
|
|
{devCTA}
|
2015-06-03 10:04:21 +08:00
|
|
|
</div>
|
2015-10-04 09:11:29 +08:00
|
|
|
<PackageSet
|
|
|
|
title="Core"
|
|
|
|
packages={@state.packages.core} />
|
2015-06-03 10:04:21 +08:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
2015-10-04 10:04:19 +08:00
|
|
|
_onEnableDevMode: =>
|
|
|
|
require('ipc').send('command', 'application:toggle-dev')
|
|
|
|
|
2015-06-03 10:04:21 +08:00
|
|
|
componentDidMount: =>
|
|
|
|
@_unsubscribers = []
|
2015-10-04 09:11:29 +08:00
|
|
|
@_unsubscribers.push PackagesStore.listen(@_onChange)
|
2015-06-03 10:04:21 +08:00
|
|
|
|
2015-10-04 09:11:29 +08:00
|
|
|
PluginsActions.refreshInstalledPackages()
|
2015-06-03 10:04:21 +08:00
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
unsubscribe() for unsubscribe in @_unsubscribers
|
|
|
|
|
|
|
|
_getStateFromStores: =>
|
2015-10-04 09:11:29 +08:00
|
|
|
packages: PackagesStore.installed()
|
|
|
|
search: PackagesStore.installedSearchValue()
|
2015-06-03 10:04:21 +08:00
|
|
|
|
|
|
|
_onChange: =>
|
|
|
|
@setState(@_getStateFromStores())
|
|
|
|
|
|
|
|
_onCreatePackage: =>
|
2015-10-04 09:11:29 +08:00
|
|
|
PluginsActions.createPackage()
|
2015-06-03 10:04:21 +08:00
|
|
|
|
|
|
|
_onSearchChange: (event) =>
|
2015-10-04 09:11:29 +08:00
|
|
|
PluginsActions.setInstalledSearchValue(event.target.value)
|
2015-06-03 10:04:21 +08:00
|
|
|
|
|
|
|
module.exports = TabInstalled
|