// @flow import type {Plugin} from '../../../plugins/index'; import {createPlugin, getPlugins} from '../../../plugins/index'; import React from 'react'; import autobind from 'autobind-decorator'; import * as electron from 'electron'; import Button from '../base/button'; import CopyButton from '../base/copy-button'; import {showPrompt} from '../modals/index'; import {trackEvent} from '../../../analytics/index'; import {reload} from '../../../templating/index'; type DefaultProps = void; type Props = void; type State = { plugins: Array, npmPluginValue: string }; @autobind class Plugins extends React.PureComponent { props: Props; state: State; constructor (props: Props) { super(props); this.state = { plugins: [], npmPluginValue: '' }; } _handleAddNpmPluginChange (e: Event & {target: HTMLButtonElement}) { this.setState({npmPluginValue: e.target.value}); } _handleAddFromNpm () { console.log('ADD FROM NPM', this.state.npmPluginValue); } _handleOpenDirectory (directory: string) { electron.remote.shell.showItemInFolder(directory); } _handleGeneratePlugin () { showPrompt({ title: 'Plugin Name', defaultValue: 'My Plugin', submitName: 'Generate Plugin', selectText: true, placeholder: 'My Cool Plugin', label: 'Plugin Name', onComplete: async name => { await createPlugin(name); await this._handleRefreshPlugins(); trackEvent('Plugins', 'Generate'); } }); } async _handleRefreshPlugins () { // Get and reload plugins const plugins = await getPlugins(true); reload(); this.setState({plugins}); trackEvent('Plugins', 'Refresh'); } componentDidMount () { this._handleRefreshPlugins(); } render () { const {plugins} = this.state; return (

Plugins are experimental and compatibility may break in future releases

{plugins.map(plugin => ( ))}
Name Version Folder
{plugin.name} {plugin.version} Copy Path {' '}

); } } export default Plugins;