import React from 'react'; import {Flexbox, RetinaImg, Switch} from 'nylas-component-kit'; import PluginsActions from './plugins-actions'; class Package extends React.Component { static displayName = 'Package'; static propTypes = { package: React.PropTypes.object.isRequired, } constructor() { super(); } _onDisablePackage = () => { PluginsActions.disablePackage(this.props.package); } _onEnablePackage = () => { PluginsActions.enablePackage(this.props.package); } _onUninstallPackage = () => { PluginsActions.uninstallPackage(this.props.package); } _onUpdatePackage = () => { PluginsActions.updatePackage(this.props.package); } _onInstallPackage = () => { PluginsActions.installPackage(this.props.package); } _onShowPackage = () => { PluginsActions.showPackage(this.props.package); } render() { const actions = []; const extras = []; let icon = (); let uninstallButton = null; if (this.props.package.icon) { icon = (); } else if (this.props.package.theme) { icon = (); } if (this.props.package.installed) { if (['user', 'dev', 'example'].indexOf(this.props.package.category) !== -1 && !this.props.package.theme) { if (this.props.package.enabled) { actions.push(Disable); } else { actions.push(Enable); } } if (this.props.package.category === 'user') { uninstallButton =
Uninstall
} if (this.props.package.category === 'dev') { actions.push(
Show...
); } } else if (this.props.package.installing) { actions.push(
Installing...
); } else { actions.push(
Install
); } const {name, description, title} = this.props.package; if (this.props.package.newerVersionAvailable) { extras.push(
A newer version is available: {this.props.package.newerVersion}
Update
) } return (
{icon}
{title || name}
{uninstallButton}
{description}
{actions}
{extras}
); } } export default Package;