Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (7 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/archive/browse/browse.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';
     7import { localize } from 'i18n-calypso';
    28
     9/**
     10 * Internal dependencies.
     11 */
    312import ContentNone from 'components/content-none';
     13import { getSection, getSectionPlugins } from 'state/selectors';
     14import Pagination from 'components/pagination';
    415import PluginCard from 'components/plugin-card';
    516
    6 export default React.createClass( {
    7     displayName: 'ArchiveBrowse',
     17export const ArchiveBrowse = ( { plugins, section, translate } ) => {
     18    if ( plugins && plugins.length ) {
     19        return (
     20            <div>
     21                <header className="page-header">
     22                    <h1 className="page-title">
     23                        { translate( 'Browse: {{strong}}%(name)s{{/strong}}', {
     24                            args: { name: section.name },
     25                            components: { strong: <strong /> },
     26                        } ) }
     27                    </h1>
     28                    { section.description &&
     29                        <div className="taxonomy-description">{ section.description }</div>
     30                    }
     31                </header>
     32                { plugins.map( ( plugin ) => <PluginCard key={ plugin.id } plugin={ plugin } /> ) }
     33                <Pagination current={ 12 } total={ 30 } />
     34            </div>
     35        );
     36    }
    837
    9     render() {
    10         if ( this.props.plugins && this.props.plugins.length ) {
    11             return (
    12                 <div>
    13                     <header className="page-header">
    14                         <h1 className="page-title">Browse: <strong>{ this.props.params.type }</strong></h1>
    15                         <div className="taxonomy-description"></div>
    16                     </header>
    17                     { this.props.plugins.map( slug =>
    18                         <PluginCard key={ slug } slug={ slug } />
    19                     ) }
    20                 </div>
    21             )
    22         }
     38    return <ContentNone />;
     39};
    2340
    24         return <ContentNone { ...this.props } />;
    25     }
    26 } );
     41ArchiveBrowse.propTypes = {
     42    plugins: PropTypes.arrayOf( PropTypes.object ),
     43    section: PropTypes.object,
     44    translate: PropTypes.func,
     45    type: PropTypes.string.isRequired,
     46};
     47
     48ArchiveBrowse.defaultProps = {
     49    plugins: [],
     50    section: {},
     51    translate: identity,
     52};
     53
     54export default connect(
     55    ( state, { type } ) => ( {
     56        plugins: getSectionPlugins( state, type ),
     57        section: getSection( state, type ),
     58    } ),
     59)( localize( ArchiveBrowse ) );
Note: See TracChangeset for help on using the changeset viewer.