Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Update React client with latest changes.

This is largely a cleanup commit with some WIP around switching to node-wpapi.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/client/components/front-page/plugin-section/plugin-section.jsx

    r4223 r5024  
    1 import React from 'react';
     1/**
     2 * External dependencies.
     3 */
     4import React, { PropTypes } from 'react';
     5import { connect } from 'react-redux';
     6import { identity } from 'lodash';
    27import { Link } from 'react-router';
     8import { localize } from 'i18n-calypso';
    39
    410/**
    511 * Internal dependencies.
    612 */
     13import { getSection, getSectionPlugins } from 'state/selectors';
    714import PluginCard from 'components/plugin-card';
    815
    9 export default React.createClass( {
    10         displayName: 'PluginSection',
    11 
    12         render() {
    13                 if ( ! this.props.plugins ) {
    14                         return <div />;
    15                 }
    16 
     16/**
     17 *
     18 * @param {Array}       plugins   Plugins
     19 * @param {Object}      section   Section
     20 * @param {Function}    translate Translation function
     21 * @return {(XML|null)}           Component or null.
     22 * @constructor
     23 */
     24export const PluginSection = ( { plugins, section, translate } ) => {
     25        if ( plugins ) {
    1726                return (
    1827                        <section className="plugin-section">
    1928                                <header className="section-header">
    20                                         <h2 className="section-title">{ this.props.section.title }</h2>
    21                                         <Link className="section-link" to={ this.props.section.path }>See all</Link>
     29                                        <h2 className="section-title">{ section.name }</h2>
     30                                        <Link className="section-link" to={ `/browse/${ section.slug }/` }>{ translate( 'See all' ) }</Link>
    2231                                </header>
    23                                 { this.props.plugins.map( slug =>
    24                                         <PluginCard key={ slug } slug={ slug } />
    25                                 ) }
     32                                { plugins.map( ( plugin ) => <PluginCard key={ plugin.id } plugin={ plugin } /> ) }
    2633                        </section>
    27                 )
     34                );
    2835        }
    29 } );
     36
     37        return null;
     38};
     39
     40PluginSection.propTypes = {
     41        plugins: PropTypes.array,
     42        section: PropTypes.object,
     43        translate: PropTypes.func,
     44};
     45
     46PluginSection.defaultProps = {
     47        plugins: [],
     48        section: {},
     49        translate: identity,
     50};
     51
     52export default connect(
     53        ( state, { type } ) => ( {
     54                plugins: getSectionPlugins( state, type ).slice( 0, 4 ),
     55                section: getSection( state, type ),
     56        } ),
     57)( localize( PluginSection ) );
Note: See TracChangeset for help on using the changeset viewer.