/** * * PluginCard * */ /* eslint-disable */ import React from 'react'; import PropTypes from 'prop-types'; import { FormattedMessage } from 'react-intl'; import { Button, PopUpWarning } from 'strapi-helper-plugin'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import Wrapper from './Wrapper'; const PLUGINS_WITH_CONFIG = ['email']; /* eslint-disable react/no-unused-state */ class PluginCard extends React.Component { state = { boostrapCol: 'col-lg-4', showModalAutoReload: false, showModalEnv: false, }; componentDidMount() { // Listen window resize. window.addEventListener('resize', this.setBoostrapCol); this.setBoostrapCol(); } componentWillUnmount() { window.removeEventListener('resize', this.setBoostrapCol); } setBoostrapCol = () => { let boostrapCol = 'col-lg-4'; if (window.innerWidth > 1680) { boostrapCol = 'col-lg-3'; } if (window.innerWidth > 2300) { boostrapCol = 'col-lg-2'; } this.setState({ boostrapCol }); }; handleClick = () => { if (this.props.plugin.id !== 'support-us') { this.props.history.push({ pathname: this.props.history.location.pathname, hash: `${this.props.plugin.id}::description`, }); } else { this.aTag.click(); } }; handleClickSettings = e => { const settingsPath = `/plugins/${this.props.plugin.id}/configurations/${this.props.currentEnvironment}`; e.preventDefault(); e.stopPropagation(); this.props.history.push(settingsPath); }; handleDownloadPlugin = e => { const { autoReload, currentEnvironment, downloadPlugin, history: { push }, isAlreadyInstalled, plugin: { id }, } = this.props; if (!autoReload) { this.setState({ showModalAutoReload: true }); } else if (currentEnvironment !== 'development') { this.setState({ showModalEnv: true }); } else if (!isAlreadyInstalled) { downloadPlugin(id); } else { push('/list-plugins'); } }; render() { const buttonClass = !this.props.isAlreadyInstalled ? 'primary' : 'secondary'; const buttonLabel = this.props.isAlreadyInstalled ? 'app.components.PluginCard.Button.label.install' : 'app.components.PluginCard.Button.label.download'; // Display settings link for a selection of plugins. const settingsComponent = PLUGINS_WITH_CONFIG.includes(this.props.plugin.id) && (