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/modules/router.jsx

    r4223 r5024  
    1 /* global add_data:object */
     1/**
     2 * External dependencies.
     3 */
    24import React from 'react';
    3 import { connect } from 'react-redux';
    4 import { Router, Route, IndexRoute, useRouterHistory } from 'react-router';
    5 import createBrowserHistory from 'history/lib/createBrowserHistory';
     5import { Route, IndexRoute } from 'react-router';
     6import { ReduxRouter } from 'redux-router';
    67
     8/**
     9 * Internal dependencies.
     10 */
    711import ArchiveBrowse from 'components/archive/browse';
    812import FrontPage from 'components/front-page';
     
    1519import SiteMain from 'components/site-main';
    1620
    17 const history = useRouterHistory( createBrowserHistory )( {
    18     /** @type {object} app_data Description */
    19     basename: app_data.base
    20 } );
     21const onUpdate = () => window.scrollTo( 0, 0 );
     22
     23export const routes = (
     24    <Route name="root" component={ PluginDirectory }>
     25        <Route path="/" components={ { header: SiteHeader, main: SiteMain } }>
     26            <IndexRoute component={ FrontPage } />
     27            <Route path="browse/favorites/:username" component={ ArchiveBrowse } />
     28            <Route path="browse/:type/page/:page" component={ ArchiveBrowse } />
     29            <Route path="browse/:type" component={ ArchiveBrowse } />
     30            <Route path="developers" component={ Page } />
     31            <Route path="search/:search" component={ Search } />
     32            <Route path=":slug" component={ Plugin } />
     33            <Route path="*" component={ NotFound } />
     34        </Route>
     35    </Route>
     36);
    2137
    2238export default (
    23     <Router history={ history } onUpdate={ () => window.scrollTo( 0, 0 ) }>
    24         <Route name="root" component={ PluginDirectory }>
    25             <Route path="/" components={ { header: SiteHeader, main: SiteMain } }>
    26                 <IndexRoute component={ FrontPage } />
    27                 <Route path="browse/favorites/:username" component={ ArchiveBrowse } />
    28                 <Route path="browse/:type" component={ ArchiveBrowse } />
    29                 <Route path="developers" component={ Page } />
    30                 <Route path="search/:searchTerm" component={ Search } />
    31                 <Route path=":slug" component={ Plugin } />
    32                 <Route path="*" component={ NotFound } />
    33             </Route>
    34         </Route>
    35     </Router>
     39    <ReduxRouter onUpdate={ onUpdate }>
     40        { routes }
     41    </ReduxRouter>
    3642);
Note: See TracChangeset for help on using the changeset viewer.