Making WordPress.org


Ignore:
Timestamp:
07/28/2016 10:55:18 PM (9 years ago)
Author:
obenland
Message:

Plugin Directory: Restructure containers and components.

Merges containers with their components and adopts a folder hierarchy similar
to the actual element hierarchy. The exception to the rule are reusable
components.

This also adds support for displaying plugins in the plugin_section taxonomy.

See #1719.

Location:
sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/front-page
Files:
2 added
1 copied

Legend:

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

    r3717 r3734  
     1import React, { Component } from 'react';
    12import { connect } from 'react-redux';
    23
     
    45 * Internal dependencies.
    56 */
    6 import PluginSection from 'components/plugin-section';
     7import { getBrowse } from 'actions';
     8import PluginSection from './plugin-section';
    79
    8 const mapStateToProps = () => ( {
    9     plugins:  [
    10         {
    11             id: 0,
    12             slug: 'zero',
    13             title: {
    14                 rendered: 'Zero'
    15             },
    16             excerpt: 'An excerpt for Zero',
    17             rating: 4.5,
    18             rating_count: 345
    19         },
    20         {
    21             id: 1,
    22             slug: 'one',
    23             title: {
    24                 rendered: 'One'
    25             },
    26             excerpt: 'An excerpt for One',
    27             rating: 4.5,
    28             rating_count: 345
    29         },
    30         {
    31             id: 2,
    32             slug: 'two',
    33             title: {
    34                 rendered: 'Two'
    35             },
    36             excerpt: 'An excerpt for Two',
    37             rating: 4.5,
    38             rating_count: 345
     10class PluginSectionContainer extends Component {
     11    componentDidMount() {
     12        this.getBrowse();
     13    }
     14
     15    componentDidUpdate( previousProps ) {
     16        if ( this.props.section.type !== previousProps.section.type ) {
     17            this.getBrowse();
    3918        }
    40     ] //todo
     19    }
     20
     21    getBrowse() {
     22        this.props.dispatch( getBrowse( this.props.section.type ) );
     23    }
     24
     25    render() {
     26        return <PluginSection { ...this.props } />;
     27    }
     28}
     29
     30const mapStateToProps = ( state, ownProps ) => ( {
     31    plugins: state.browse[ ownProps.section.type ].slice( 0, 4 )
    4132} );
    4233
    43 export default connect( mapStateToProps )( PluginSection );
     34export default connect( mapStateToProps )( PluginSectionContainer );
Note: See TracChangeset for help on using the changeset viewer.