/** * * PluginCard * */ import React from 'react'; import PropTypes from 'prop-types'; import cn from 'classnames'; import { isEmpty, map, times } from 'lodash'; import { FormattedMessage } from 'react-intl'; // Temporary picture import Button from 'components/Button'; import FakeScreenShot from './screenshot.png'; import styles from './styles.scss'; class PluginCard extends React.Component { state = { isOpen: false }; componentDidMount() { this.shouldOpenModal(this.props); } componentWillReceiveProps(nextProps) { if (nextProps.history.location.hash !== this.props.history.location.hash) { this.shouldOpenModal(nextProps); } } shouldOpenModal = (props) => { this.setState({ isOpen: !isEmpty(props.history.location.hash) }); } render() { const stars = Math.round(this.props.plugin.ratings); const coloredStars = times(stars, String); const emptyStars = times(5 - stars, String); 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'; } return (