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/archive
Files:
2 added
1 moved

Legend:

Unmodified
Added
Removed
  • sites/trunk/wordpress.org/public_html/wp-content/themes/pub/wporg-plugins/js/client/components/archive/browse/index.jsx

    r3733 r3734  
    1 import React from 'react';
     1import React, { Component } from 'react';
     2import { connect } from 'react-redux';
    23
    34/**
    45 * Internal dependencies.
    56 */
     7import { getBrowse } from 'actions';
    68import ContentNone from 'components/content-none';
     9import PluginCard from 'components/plugin-card';
    710
    8 export default React.createClass( {
     11
     12const ArchiveBrowse = React.createClass( {
    913    displayName: 'ArchiveBrowse',
    1014
    1115    render() {
    12         let content = <ContentNone { ...this.props } />;
    13 
    14         if ( false /*this.props.plugins.length*/ ) {
    15             content = <header className="page-header">
    16                 <h1 className="page-title"></h1>
    17                 <div className="taxonomy-description"></div>
    18             </header>
    19 
    20             content += this.props.plugins.map( plugin => <PluginCard key={ plugin.slug } plugin={ plugin } /> );
     16        if ( this.props.plugins ) {
     17            return (
     18                <div>
     19                    <header className="page-header">
     20                        <h1 className="page-title">Browse: <strong>{ this.props.params.type }</strong></h1>
     21                        <div className="taxonomy-description"></div>
     22                    </header>
     23                    { this.props.plugins.map( slug =>
     24                        <PluginCard key={ slug } slug={ slug } />
     25                    ) }
     26                </div>
     27            )
    2128        }
    2229
    23         return (
    24             <div>{ content }</div>
    25         )
     30        return <ContentNone { ...this.props } />;
    2631    }
    2732} );
     33
     34class ArchiveBrowseContainer extends Component {
     35    componentDidMount() {
     36        this.getBrowse();
     37    }
     38
     39    componentDidUpdate( previousProps ) {
     40        if ( this.props.params.type !== previousProps.params.type ) {
     41            this.getBrowse();
     42        }
     43    }
     44
     45    getBrowse() {
     46        this.props.dispatch( getBrowse( this.props.params.type ) );
     47    }
     48
     49    render() {
     50        return <ArchiveBrowse { ...this.props } />;
     51    }
     52}
     53
     54const mapStateToProps = ( state, ownProps ) => ( {
     55    plugins: state.browse[ ownProps.params.type ]
     56} );
     57
     58export default connect( mapStateToProps )( ArchiveBrowseContainer );
     59
     60
Note: See TracChangeset for help on using the changeset viewer.