Changeset 3734 for sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/plugin-card/index.jsx
- Timestamp:
- 07/28/2016 10:55:18 PM (9 years ago)
- Location:
- sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/plugin-card
- Files:
-
- 1 added
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/plugin-card/index.jsx
r3733 r3734 1 import React from 'react'; 1 import React, { Component } from 'react'; 2 import { connect } from 'react-redux'; 3 import find from 'lodash/find'; 2 4 import { Link } from 'react-router'; 3 5 4 export default React.createClass( { 6 /** 7 * Internal dependencies. 8 */ 9 import { getPlugin } from 'actions'; 10 import PluginRatings from 'components/plugin-ratings'; 11 12 const PluginCard = React.createClass( { 5 13 displayName: 'PluginCard', 6 14 7 15 render() { 16 if ( ! this.props.plugin ) { 17 return ( 18 <div /> 19 ); 20 } 21 8 22 return ( 9 23 <article className="plugin type-plugin"> … … 12 26 <header className="entry-header"> 13 27 <h2 className="entry-title"> 14 <Link to={ this.props.plugin.slug } rel="bookmark">{ this.props.plugin. title.rendered}</Link>28 <Link to={ this.props.plugin.slug } rel="bookmark">{ this.props.plugin.name }</Link> 15 29 </h2> 16 30 </header> 17 <div className="plugin-rating" itemProp="aggregateRating" itemScope itemType="http://schema.org/AggregateRating">18 <meta itemProp="ratingCount" content={ this.props.plugin.rating_count } />19 <meta itemProp="ratingValue" content={ this.props.plugin.rating } />20 31 21 <div className="wporg-ratings"></div> 22 <span className="rating-count">({ this.props.plugin.rating_count })</span> 23 </div> 24 <div className="entry-excerpt">{ this.props.plugin.excerpt }</div> 32 <PluginRatings rating={ this.props.plugin.rating } ratingCount={ this.props.plugin.num_ratings } /> 33 34 <div className="entry-excerpt">{ this.props.plugin.short_description }</div> 25 35 </div> 26 36 </article> … … 28 38 } 29 39 } ); 40 41 class PluginCardContainer extends Component { 42 componentDidMount() { 43 this.getPlugin(); 44 } 45 46 componentDidUpdate( previousProps ) { 47 if ( this.props.slug !== previousProps.slug ) { 48 this.getPlugin(); 49 } 50 } 51 52 getPlugin() { 53 this.props.dispatch( getPlugin( this.props.slug ) ); 54 } 55 56 render() { 57 return <PluginCard { ...this.props } />; 58 } 59 } 60 61 const mapStateToProps = ( state, ownProps ) => ( { 62 plugin: find( state.plugins, { slug: ownProps.slug } ) 63 } ); 64 65 export default connect( mapStateToProps )( PluginCardContainer ); 66 67
Note: See TracChangeset
for help on using the changeset viewer.