React router #343
|
@ -6,7 +6,7 @@ class AboutPage extends React.Component {
|
||||||
return (
|
return (
|
||||||
<div>
|
<div>
|
||||||
<NavBar/>
|
<NavBar/>
|
||||||
<h1>About page</h1>;
|
<h1>About page</h1>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
import React from 'react';
|
import React from 'react';
|
||||||
import request from 'utils/request';
|
import { Link, withRouter } from 'react-router-dom';
|
||||||
import Logo from 'components/Logo';
|
import Logo from 'components/Logo';
|
||||||
import NavBarChannelDropdown from 'components/NavBarChannelOptionsDropdown';
|
import NavBarChannelDropdown from 'components/NavBarChannelOptionsDropdown';
|
||||||
|
import request from 'utils/request';
|
||||||
|
|
||||||
const VIEW = 'VIEW';
|
const VIEW = 'VIEW';
|
||||||
const LOGOUT = 'LOGOUT';
|
const LOGOUT = 'LOGOUT';
|
||||||
|
@ -48,7 +49,7 @@ class NavBar extends React.Component {
|
||||||
break;
|
break;
|
||||||
case VIEW:
|
case VIEW:
|
||||||
// redirect to channel page
|
// redirect to channel page
|
||||||
window.location.href = `/${this.props.channelName}:${this.props.channelLongId}`;
|
this.props.history.push(`/${this.props.channelName}:${this.props.channelLongId}`);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
@ -63,8 +64,8 @@ class NavBar extends React.Component {
|
||||||
<span className="nav-bar-tagline">Open-source, decentralized image and video sharing.</span>
|
<span className="nav-bar-tagline">Open-source, decentralized image and video sharing.</span>
|
||||||
</div>
|
</div>
|
||||||
<div className="nav-bar--right">
|
<div className="nav-bar--right">
|
||||||
<a className="nav-bar-link link--nav-active" href="/">Publish</a>
|
<Link className="nav-bar-link link--nav-active" to="/">Publish</Link>
|
||||||
<a className="nav-bar-link link--nav" href="/about">About</a>
|
<Link className="nav-bar-link link--nav" to="/about">About</Link>
|
||||||
{ this.props.channelName ? (
|
{ this.props.channelName ? (
|
||||||
<NavBarChannelDropdown
|
<NavBarChannelDropdown
|
||||||
channelName={this.props.channelName}
|
channelName={this.props.channelName}
|
||||||
|
@ -73,7 +74,7 @@ class NavBar extends React.Component {
|
||||||
LOGOUT={LOGOUT}
|
LOGOUT={LOGOUT}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<a id="nav-bar-login-link" className="nav-bar-link link--nav" href="/login">Channel</a>
|
<Link id="nav-bar-login-link" className="nav-bar-link link--nav" to="/login">Channel</Link>
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -82,4 +83,4 @@ class NavBar extends React.Component {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export default NavBar;
|
export default withRouter(NavBar);
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import { Provider } from 'react-redux';
|
import { Provider } from 'react-redux';
|
||||||
import { BrowserRouter as Router, Route } from 'react-router-dom';
|
import { BrowserRouter, Route, Switch } from 'react-router-dom';
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
|
||||||
import PublishPage from 'components/PublishPage';
|
import PublishPage from 'components/PublishPage';
|
||||||
import AboutPage from 'components/AboutPage';
|
import AboutPage from 'components/AboutPage';
|
||||||
|
@ -9,9 +9,13 @@ import LoginPage from 'components/LoginPage';
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
|
||||||
const Root = ({ store }) => (
|
const Root = ({ store }) => (
|
||||||
<Provider store={store}>
|
<Provider store={store}>
|
||||||
<Router>
|
<BrowserRouter>
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
<Route exact path="/" component={PublishPage} />
|
<Switch>
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
</Router>
|
<Route exact path="/" component={PublishPage} />
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
<Route exact path="/about" component={AboutPage} />
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
<Route exact path="/login" component={LoginPage} />
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
</Switch>
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
|
</BrowserRouter>
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
|||||||
</Provider>
|
</Provider>
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a `Redirect` component or just a route with no `path` prop.
|
Probably worth adding a 404 page or just redirect to the homepage if it doesn't find a route. Either with a
Redirect
component or just a route with nopath
prop.