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."
<div className="installed">
<div className="inner">
<input
type="search"
value={@state.search}
onChange={@_onSearchChange }
placeholder="Search Installed Packages"/>
<PackageSet
packages={@state.packages.user}
2015-10-04 09:11:29 +08:00
title="Installed"
emptyText={searchEmpty ? "You don't have any packages installed in ~/.nylas/packages."} />
2015-06-03 10:04:21 +08:00
<PackageSet
title="Development"
packages={@state.packages.dev}
2015-10-04 09:11:29 +08:00
emptyText={searchEmpty ? <span>You don't have any packages installed in ~/.nylas/dev/packages. These packages are only loaded when you run the app with debug flags enabled (via the Developer menu).<br/><br/>Learn more about building packages at <a href='https://nylas.github.io/N1/docs'>https://nylas.github.io/N1/docs</a></span>} />
2015-06-03 10:04:21 +08:00
<div className="new-package">
<div className="btn btn-large" onClick={@_onCreatePackage}>Create New Package...</div>
</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>
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