/** * * PluginCard * */ import React from 'react'; import PropTypes from 'prop-types'; import cn from 'classnames'; import { isEmpty, replace } from 'lodash'; import { FormattedMessage } from 'react-intl'; // Temporary picture import Button from 'components/Button'; import InstallPluginPopup from 'components/InstallPluginPopup'; import Official from 'components/Official'; // import StarsContainer from 'components/StarsContainer'; import logoTShirt from 'assets/images/logo-t-shirt.svg'; import styles from './styles.scss'; import Screenshot from './screenshot.png'; class PluginCard extends React.Component { state = { isOpen: false, boostrapCol: 'col-lg-4' }; componentDidMount() { this.shouldOpenModal(this.props); window.addEventListener('resize', this.setBoostrapCol); this.setBoostrapCol(); } componentWillReceiveProps(nextProps) { if (nextProps.history.location.hash !== this.props.history.location.hash) { this.shouldOpenModal(nextProps); } } 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(); } } handleDownloadPlugin = (e) => { if (!this.props.isAlreadyInstalled && this.props.plugin.id !== 'support-us') { this.props.downloadPlugin(e); } else if (this.props.plugin.id === 'support-us') { this.aTag.click(); } else { this.props.history.push('/list-plugins'); } } shouldOpenModal = (props) => { this.setState({ isOpen: !isEmpty(props.history.location.hash) }); } render() { const buttonClass = !this.props.isAlreadyInstalled || this.props.showSupportUsButton ? styles.primary : styles.secondary; let buttonLabel = this.props.isAlreadyInstalled ? 'app.components.PluginCard.Button.label.install' : 'app.components.PluginCard.Button.label.download'; if (this.props.showSupportUsButton) { buttonLabel = 'app.components.PluginCard.Button.label.support'; } const pluginIcon = (