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/plugin/plugin.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';
     8import { values } from 'lodash';
    29
     10/**
     11 * Internal dependencies.
     12 */
    313import Developers from './sections/developers';
    414import DonateWidget from 'components/widget-area/widgets/donate';
     
    616import FAQ from './sections/faq';
    717import FavoriteButton from './favorite-button';
     18import { getPlugin } from 'state/selectors';
    819import MetaWidget from 'components/widget-area/widgets/meta/index';
    920import PluginBanner from './plugin-banner';
     
    1526import SupportWidget from 'components/widget-area/widgets/support/index';
    1627
    17 export default React.createClass( {
    18     displayName: 'Plugin',
    19 
    20     render() {
    21         if ( ! this.props.plugin ) {
    22             return (
    23                 <article className="plugin type-plugin">
    24                     <header className="entry-header">
    25                         <h1 className="entry-title"> </h1>
    26                     </header>
    27                     <div className="entry-content">
    28                         <section>
    29                             <div className="container"> LOADING </div>
    30                         </section>
    31                     </div>
    32                 </article>
    33             )
    34         }
    35 
     28export const Plugin = ( { plugin, translate } ) => {
     29    if ( ! plugin ) {
    3630        return (
    3731            <article className="plugin type-plugin">
    38                 <PluginBanner plugin={ this.props.plugin } />
    39                 <header className="plugin-header">
    40                     <PluginIcon plugin={ this.props.plugin } />
    41                     <div className="plugin-actions">
    42                         <FavoriteButton plugin={ this.props.plugin } />
    43                         <DownloadButton plugin={ this.props.plugin } />
    44                     </div>
    45                     <h1 className="plugin-title">{ this.props.plugin.name }</h1>
    46                     <span className="byline">By <span className="author vcard" dangerouslySetInnerHTML={ { __html: this.props.plugin.author } } /></span>
     32                <header className="entry-header">
     33                    <h1 className="entry-title"> </h1>
    4734                </header>
    4835                <div className="entry-content">
    49                     <Section slug="description" title="Description" content={ this.props.plugin.sections.description } />
    50                     <Screenshots screenshots={ this.props.plugin.screenshots } />
    51                     <FAQ content={ this.props.plugin.sections.faq } />
    52                     <Reviews slug={ this.props.plugin.slug } content={ this.props.plugin.sections.reviews } numRatings={ this.props.plugin.num_ratings } />
    53                     <Section slug="changelog" title="Changelog" content={ this.props.plugin.sections.changelog } />
    54                     <Developers slug={ this.props.plugin.slug } contributors={ this.props.plugin.contributors } />
    55                 </div>
    56                 <div className="entry-meta">
    57                     <MetaWidget plugin={ this.props.plugin } />
    58                     <RatingsWidget plugin={ this.props.plugin } />
    59                     <SupportWidget plugin={ this.props.plugin } />
    60                     <DonateWidget plugin={ this.props.plugin } />
     36                    <section>
     37                        <div className="container"> LOADING </div>
     38                    </section>
    6139                </div>
    6240            </article>
    63         )
     41        );
    6442    }
    65 } );
     43
     44    return (
     45        <article className="plugin type-plugin">
     46            <PluginBanner />
     47            <header className="plugin-header">
     48                <PluginIcon />
     49                <div className="plugin-actions">
     50                    <FavoriteButton plugin={ plugin } />
     51                    <DownloadButton />
     52                </div>
     53                <h1 className="plugin-title" dangerouslySetInnerHTML={ { __html: plugin.title.rendered } } />
     54                <span className="byline">
     55                    { translate( 'By {{span/}}', { components: {
     56                        span: <span className="author vcard" dangerouslySetInnerHTML={ { __html: plugin.author } } />,
     57                    } } ) }
     58                </span>
     59            </header>
     60            <div className="entry-content">
     61                <Section slug="description" title="Description" content={ plugin.sections.description } />
     62                <Screenshots screenshots={ values( plugin.screenshots ) } />
     63                <FAQ content={ plugin.sections.faq } />
     64                <Reviews
     65                    slug={ plugin.slug }
     66                    content={ plugin.sections.reviews }
     67                    numRatings={ plugin.ratings.length } />
     68                <Section slug="changelog" title="Changelog" content={ plugin.sections.changelog } />
     69                <Developers />
     70            </div>
     71            <div className="entry-meta">
     72                <MetaWidget />
     73                <RatingsWidget />
     74                <SupportWidget />
     75                <DonateWidget />
     76            </div>
     77        </article>
     78    );
     79};
     80
     81Plugin.propTypes = {
     82    plugin: PropTypes.object,
     83    translate: PropTypes.func,
     84};
     85
     86Plugin.defaultProps = {
     87    plugin: {},
     88    translate: identity,
     89};
     90
     91export default connect(
     92    ( state ) => ( {
     93        plugin: getPlugin( state ),
     94    } ),
     95)( localize( Plugin ) );
Note: See TracChangeset for help on using the changeset viewer.