Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (8 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/index.jsx

    r4223 r5024  
    1 import React from 'react';
     1/**
     2 * External dependencies.
     3 */
     4import React, { Component, PropTypes } from 'react';
    25import { connect } from 'react-redux';
    3 import find from 'lodash/find';
    46
     7/**
     8 * Internal dependencies.
     9 */
    510import Plugin from './plugin';
    6 import { getPlugin } from 'actions';
     11import { fetchPlugin } from 'state/plugins/actions';
    712
    8 const PluginContainer = React.createClass( {
     13class PluginContainer extends Component {
     14    static PropTypes = {
     15        fetchPlugin: PropTypes.func,
     16        params: PropTypes.object,
     17    };
     18
     19    static defaultProps = {
     20        fetchPlugin: () => {},
     21        params: {},
     22    };
     23
    924    componentDidMount() {
    10         this.getPlugin();
    11     },
     25        this.fetchPlugin();
     26    }
    1227
    13     componentDidUpdate( previousProps ) {
    14         if ( this.props.route.path !== previousProps.route.path ) {
    15             this.getPlugin();
     28    componentDidUpdate( { params } ) {
     29        if ( this.props.params.slug !== params.slug ) {
     30            this.fetchPlugin();
    1631        }
    17     },
     32    }
    1833
    19     getPlugin() {
    20         this.props.dispatch( getPlugin( this.props.params.slug ) );
    21     },
     34    fetchPlugin() {
     35        this.props.fetchPlugin( this.props.params.slug );
     36    }
    2237
    2338    render() {
    24         return <Plugin { ...this.props } />;
     39        return <Plugin />;
    2540    }
    26 } );
     41}
    2742
    28 const mapStateToProps = ( state, ownProps ) => ( {
    29     plugin: find( state.plugins, { slug: ownProps.params.slug } )
    30 } );
    31 
    32 export default connect( mapStateToProps )( PluginContainer );
     43export default connect(
     44    null,
     45    {
     46        fetchPlugin,
     47    },
     48)( PluginContainer );
Note: See TracChangeset for help on using the changeset viewer.