Making WordPress.org


Ignore:
Timestamp:
03/01/2017 06:08:54 PM (10 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/content-none/index.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
    39/**
    410 * Internal dependencies.
    511 */
     12import { getParams, getPath } from 'state/selectors';
    613import SearchForm from 'components/search-form';
    714
    8 export default  React.createClass( {
    9         displayName: 'ContentNone',
     15export const ContentNone = ( { params, path, translate } ) => {
     16        let helpText, userHelp;
    1017
    11         render() {
    12                 let helpText, userHelp;
     18        if ( -1 !== path.indexOf( 'search' ) ) {
     19                helpText = (
     20                        <div className="page-content">
     21                                <p>{ translate( 'Sorry, but nothing matched your search terms.' ) }</p>
     22                                <p>{ translate( 'Please try again with some different keywords.' ) }</p>
     23                                <SearchForm />
     24                        </div>
     25                );
     26        } else if ( -1 !== path.indexOf( 'browse/favorites' ) ) {
     27                if ( pluginDirectory.userId > 0 ) {
     28                        helpText = <p>{ translate( 'No favorites have been added, yet.' ) }</p>;
    1329
    14                 if ( -1 !== this.props.location.pathname.indexOf( 'search' ) ) {
    15                         helpText = (
    16                                 <div className="page-content">
    17                                         <p>Sorry, but nothing matched your search terms.</p>
    18                                         <p>Please try again with some different keywords.</p>
    19                                         <SearchForm searchTerm={ this.props.params.searchTerm } />
    20                                 </div>
    21                         );
    22 
    23                 } else if ( -1 !== this.props.location.pathname.indexOf( 'browse/favorites' ) ) {
    24                         if ( true /*user_logged_in*/ ) {
    25                                 helpText = <p>No favorites have been added, yet.</p>;
    26 
    27                                 if ( -1 !== this.props.location.pathname.indexOf( 'browse/favorites/' + this.props.params.username ) ) {
    28                                         userHelp = (
    29                                                 <div>
    30                                                         <p>Find a plugin and mark it as a favorite to see it here.</p>
    31                                                         <p>Your favorite plugins are also shared on <a href={ 'https://profile.wordpress.org/' + this.props.params.username }>your profile</a></p>
    32                                                 </div>
    33                                         );
    34                                 }
    35 
    36                                 helpText = <div className="page-content">{ helpText }{ userHelp }</div>;
    37                         } else {
    38                                 helpText = (
    39                                         <div className="page-content">
    40                                                 <p><a href="https://login.wordpress.org/">Loginto WordPress.org</a> to mark plugins as favorites.</p>
     30                        if ( -1 !== path.indexOf( 'browse/favorites/' + params.username ) ) {
     31                                userHelp = (
     32                                        <div>
     33                                                <p>{ translate( 'Find a plugin and mark it as a favorite to see it here.' ) }</p>
     34                                                <p>
     35                                                        { translate( 'Your favorite plugins are also shared on {{a}}your profile{{/a}}', {
     36                                                                components: { a: <a href={ 'https://profile.wordpress.org/' + params.username } /> },
     37                                                        } ) }
     38                                                </p>
    4139                                        </div>
    4240                                );
    4341                        }
     42
     43                        helpText = <div className="page-content">{ helpText }{ userHelp }</div>;
    4444                } else {
    4545                        helpText = (
    4646                                <div className="page-content">
    47                                         <p>It seems we can&#8217;t find what you&#8217;re looking for. Perhaps searching can help.</p>
     47                                        <p>
     48                                                { translate( '{{a}}Log into WordPress.org{{/a}} to mark plugins as favorites.', {
     49                                                        components: { a: <a href="https://login.wordpress.org/" /> },
     50                                                } ) }
     51                                        </p>
    4852                                </div>
    4953                        );
     54                }
     55        } else {
     56                helpText = (
     57                        <div className="page-content">
     58                                <div className="page-content">
     59                                        <p>
     60                                                { translate(
     61                                                        'It seems we can&#8217;t find what you&#8217;re looking for. Perhaps searching can help.'
     62                                                ) }
     63                                        </p>
     64                                </div>
     65                                <SearchForm />
     66                        </div>
     67                );
     68        }
    5069
    51                         helpText = (
    52                                 <div className="page-content">
    53                                         { helpText }
    54                                         <SearchForm searchTerm={ this.props.params.searchTerm } />
    55                                 </div>
    56                         );
     70        return (
     71                <section className="no-results not-found">
     72                        <header className="page-header">
     73                                <h1 className="page-title">{ translate( 'Nothing Found' ) }</h1>
     74                        </header>
     75                        { helpText }
     76                </section>
     77        );
     78};
    5779
    58                 }
     80ContentNone.propTypes = {
     81        params: PropTypes.object,
     82        path: PropTypes.string,
     83        translate: PropTypes.func,
     84};
    5985
    60                 return (
    61                         <section className="no-results not-found">
    62                                 <header className="page-header">
    63                                         <h1 className="page-title">Nothing Found</h1>
    64                                 </header>
    65                                 { helpText }
    66                         </section>
    67                 )
    68         }
    69 } );
     86ContentNone.defaultProps = {
     87        params: {},
     88        path: '',
     89        translate: identity,
     90};
     91
     92export default connect(
     93        ( state ) => ( {
     94                params: getParams( state ),
     95                path: getPath( state ),
     96        } ),
     97)( localize( ContentNone ) );
Note: See TracChangeset for help on using the changeset viewer.