2015-09-23 11:11:51 +08:00
|
|
|
React = require 'react'
|
2015-09-30 14:58:30 +08:00
|
|
|
path = require 'path'
|
2015-09-23 11:11:51 +08:00
|
|
|
{RetinaImg, ConfigPropContainer} = require 'nylas-component-kit'
|
|
|
|
{EdgehillAPI} = require 'nylas-exports'
|
|
|
|
OnboardingActions = require './onboarding-actions'
|
2015-10-01 02:43:00 +08:00
|
|
|
InitialPackagesStore = require './initial-packages-store'
|
2015-09-23 11:11:51 +08:00
|
|
|
|
2015-10-01 02:43:00 +08:00
|
|
|
RunningPackageInstalls = 0
|
2015-09-23 11:11:51 +08:00
|
|
|
|
2015-09-30 14:58:30 +08:00
|
|
|
class InstallButton extends React.Component
|
2015-09-23 11:11:51 +08:00
|
|
|
constructor: (@props) ->
|
2015-09-30 14:58:30 +08:00
|
|
|
@state =
|
2015-11-12 02:25:11 +08:00
|
|
|
installed: NylasEnv.packages.resolvePackagePath(@props.package.name)?
|
2015-09-30 14:58:30 +08:00
|
|
|
installing: false
|
2015-09-23 11:11:51 +08:00
|
|
|
|
|
|
|
render: =>
|
2015-09-30 14:58:30 +08:00
|
|
|
classname = "btn btn-install"
|
|
|
|
classname += " installing" if @state.installing
|
|
|
|
classname += " installed" if @state.installed
|
|
|
|
|
|
|
|
<div className={classname} onClick={@_onInstall}></div>
|
|
|
|
|
|
|
|
_onInstall: =>
|
2015-10-24 03:13:20 +08:00
|
|
|
return if @state.installing or @state.installed
|
|
|
|
return unless @props.package.path
|
2015-10-01 02:43:00 +08:00
|
|
|
RunningPackageInstalls += 1
|
2015-09-30 14:58:30 +08:00
|
|
|
@setState(installing: true)
|
2015-11-12 02:25:11 +08:00
|
|
|
NylasEnv.packages.installPackageFromPath @props.package.path, (err) =>
|
2015-10-01 02:43:00 +08:00
|
|
|
RunningPackageInstalls -= 1
|
|
|
|
@props.onPackageInstaled()
|
2015-09-30 14:58:30 +08:00
|
|
|
@setState({
|
|
|
|
installing: false
|
2015-11-12 02:25:11 +08:00
|
|
|
installed: NylasEnv.packages.resolvePackagePath(@props.package.name)?
|
2015-09-30 14:58:30 +08:00
|
|
|
})
|
|
|
|
|
2015-09-25 05:51:15 +08:00
|
|
|
class InitialPackagesPage extends React.Component
|
2015-09-23 11:11:51 +08:00
|
|
|
@displayName: "InitialPackagesPage"
|
|
|
|
|
2015-10-01 02:43:00 +08:00
|
|
|
constructor: (@props) ->
|
|
|
|
@state = @getStateFromStores()
|
|
|
|
|
|
|
|
componentDidMount: =>
|
|
|
|
@unlisten = InitialPackagesStore.listen =>
|
|
|
|
@setState(@getStateFromStores())
|
|
|
|
|
|
|
|
componentWillUnmount: =>
|
|
|
|
@unlisten?()
|
|
|
|
|
|
|
|
getStateFromStores: =>
|
|
|
|
packages: InitialPackagesStore.starterPackages
|
|
|
|
error: InitialPackagesStore.lastError
|
|
|
|
|
2015-09-23 11:11:51 +08:00
|
|
|
render: =>
|
2015-09-28 17:12:35 +08:00
|
|
|
<div className="page opaque" style={width:900, height:650}>
|
2015-09-23 11:11:51 +08:00
|
|
|
<div className="back" onClick={@_onPrevPage}>
|
|
|
|
<RetinaImg name="onboarding-back.png" mode={RetinaImg.Mode.ContentPreserve}/>
|
|
|
|
</div>
|
2015-09-30 14:58:30 +08:00
|
|
|
|
2015-10-05 17:01:27 +08:00
|
|
|
<h1 style={paddingTop: 60, marginBottom: 20}>Explore plugins</h1>
|
2015-09-30 14:58:30 +08:00
|
|
|
<p style={paddingBottom: 20}>
|
2015-10-30 10:35:22 +08:00
|
|
|
Plugins lie at the heart of N1 and give it its powerful features.<br/>
|
2015-10-05 17:01:27 +08:00
|
|
|
Want to enable a few example plugins now? They'll be installed to <code>~/.nylas</code>
|
2015-09-23 11:11:51 +08:00
|
|
|
</p>
|
|
|
|
|
2015-09-30 14:58:30 +08:00
|
|
|
<div>
|
2015-10-01 02:43:00 +08:00
|
|
|
{@_renderError()}
|
|
|
|
{@state.packages.map (item) =>
|
|
|
|
<div className="initial-package" key={item.name}>
|
|
|
|
<img src={item.iconPath} style={width:50} />
|
2015-09-30 14:58:30 +08:00
|
|
|
<div className="install-container">
|
2015-10-01 02:43:00 +08:00
|
|
|
<InstallButton package={item} onPackageInstaled={@_onPackageInstaled} />
|
2015-09-30 14:58:30 +08:00
|
|
|
</div>
|
2015-10-01 02:43:00 +08:00
|
|
|
<div className="name">{item.title}</div>
|
2015-09-30 14:58:30 +08:00
|
|
|
<div className="description">{item.description}</div>
|
|
|
|
</div>
|
|
|
|
}
|
|
|
|
</div>
|
2015-10-01 02:43:00 +08:00
|
|
|
<button className="btn btn-large btn-get-started btn-emphasis"
|
|
|
|
style={marginTop: 15}
|
|
|
|
onClick={@_onGetStarted}>
|
|
|
|
{@_renderStartSpinner()}
|
|
|
|
Start Using N1
|
|
|
|
</button>
|
2015-09-23 11:11:51 +08:00
|
|
|
</div>
|
|
|
|
|
2015-10-01 02:43:00 +08:00
|
|
|
_renderError: =>
|
|
|
|
return false unless @state.error
|
|
|
|
<div className="error">{@state.error.toString()}</div>
|
|
|
|
|
|
|
|
_renderStartSpinner: =>
|
|
|
|
return false unless @state.waitingToGetStarted
|
|
|
|
<div className="spinner"></div>
|
|
|
|
|
2015-09-23 11:11:51 +08:00
|
|
|
_onPrevPage: =>
|
|
|
|
OnboardingActions.moveToPage('initial-preferences')
|
|
|
|
|
2015-10-01 02:43:00 +08:00
|
|
|
_onPackageInstaled: =>
|
|
|
|
if RunningPackageInstalls is 0 and @state.waitingToGetStarted
|
|
|
|
@_onGetStarted()
|
|
|
|
|
2015-09-23 11:11:51 +08:00
|
|
|
_onGetStarted: =>
|
2015-10-01 02:43:00 +08:00
|
|
|
if RunningPackageInstalls > 0
|
|
|
|
@setState(waitingToGetStarted: true)
|
|
|
|
else
|
|
|
|
require('ipc').send('account-setup-successful')
|
2015-09-23 11:11:51 +08:00
|
|
|
|
|
|
|
module.exports = InitialPackagesPage
|