Mailspring/internal_packages/settings/lib/package.cjsx
Ben Gotow a3b45cf33a feature(package-management): Package management interface, APM integration
Summary:
Update a few more packages to deactivate properly

Miscelaneous fixes

Initial commit of new settings package

WIP

WIP - can load and unload and install / uninstall

Click to create new boilerplate package, package updating

Test Plan: Run tests

Reviewers: evan

Reviewed By: evan

Differential Revision: https://phab.nylas.com/D1582
2015-06-02 19:04:21 -07:00

70 lines
2.1 KiB
CoffeeScript

React = require 'react'
_ = require 'underscore'
SettingsActions = require './settings-actions'
class Package extends React.Component
@displayName: 'Package'
@propTypes:
'package': React.PropTypes.object.isRequired
constructor: (@props) ->
render: =>
actions = []
extras = []
if @props.package.installed
if @props.package.enabled
actions.push <div className="btn btn-small" onClick={@_onDisablePackage}>Disable</div>
else
actions.push <div className="btn btn-small" onClick={@_onEnablePackage}>Enable</div>
if @props.package.category is 'user'
actions.push <div className="btn btn-small" onClick={@_onUninstallPackage}>Uninstall</div>
if @props.package.category is 'dev'
actions.push <div className="btn btn-small" onClick={@_onShowPackage}>Show...</div>
else if @props.package.installing
actions.push <div className="btn btn-small">Installing...</div>
else
actions.push <div className="btn btn-small" onClick={@_onInstallPackage}>Install</div>
{name, description} = @props.package
if @props.package.newerVersionAvailable
extras.push(
<div className="padded update-info">
A newer version is available: {@props.package.newerVersion}
<div className="btn btn-small btn-emphasis" onClick={@_onUpdatePackage}>Update</div>
</div>
)
<div className="package">
<div className="padded">
<div className="actions">{actions}</div>
<div className="title">{name}</div>
<div className="description">{description}</div>
</div>
{extras}
</div>
_onDisablePackage: =>
SettingsActions.disablePackage(@props.package)
_onEnablePackage: =>
SettingsActions.enablePackage(@props.package)
_onUninstallPackage: =>
SettingsActions.uninstallPackage(@props.package)
_onUpdatePackage: =>
SettingsActions.updatePackage(@props.package)
_onInstallPackage: =>
SettingsActions.installPackage(@props.package)
_onShowPackage: =>
SettingsActions.showPackage(@props.package)
module.exports = Package