import React from 'react'; import {ipcRenderer} from 'electron'; import {Flexbox} from 'nylas-component-kit'; import PackageSet from './package-set'; import PackagesStore from './packages-store'; import PluginsActions from './plugins-actions'; class TabInstalled extends React.Component { static displayName = 'TabInstalled'; constructor() { super(); this.state = this._getStateFromStores(); } componentDidMount() { this._unsubscribers = []; this._unsubscribers.push(PackagesStore.listen(this._onChange)); PluginsActions.refreshInstalledPackages(); } componentWillUnmount() { this._unsubscribers.forEach(unsubscribe => unsubscribe()); } _getStateFromStores() { return { packages: PackagesStore.installed(), search: PackagesStore.installedSearchValue(), }; } _onChange = () => { this.setState(this._getStateFromStores()); } _onInstallPackage() { PluginsActions.installNewPackage(); } _onCreatePackage() { PluginsActions.createPackage(); } _onSearchChange = (event) => { PluginsActions.setInstalledSearchValue(event.target.value); } _onEnableDevMode() { ipcRenderer.send('command', 'application:toggle-dev'); } render() { let searchEmpty = null; if (this.state.search.length > 0) { searchEmpty = "No matching packages."; } let devPackages = [] let devEmpty = (Run with debug flags enabled to load ~/.nylas-mail/dev/packages.); let devCTA = (
Enable Debug Flags
); if (NylasEnv.inDevMode()) { devPackages = this.state.packages.dev || []; devEmpty = ( {`You don't have any packages installed in ~/.nylas-mail/dev/packages. `} These plugins are only loaded when you run the app with debug flags enabled (via the Developer menu).

Learn more about building plugins with our docs.
); devCTA = (
Create New Plugin...
); } return (
Install Plugin...
{`You don't have any plugins installed in ~/.nylas-mail/packages.`}} />
{devCTA}
); } } export default TabInstalled;