fix: redirect when a collection doesn't exist (#2208)

This commit is contained in:
Damien Duhamel 2019-04-02 21:57:42 +02:00 committed by Shawn Erquhart
parent 0da6ff1a5b
commit 9e08b65502

View File

@ -177,7 +177,14 @@ class App extends React.Component {
<Redirect exact from="/" to={defaultPath} />
<Redirect exact from="/search/" to={defaultPath} />
{hasWorkflow ? <Route path="/workflow" component={Workflow} /> : null}
<Route exact path="/collections/:name" component={Collection} />
<Route
exact
path="/collections/:name"
render={props => {
const collectionExists = collections.get(props.match.params.name);
return collectionExists ? <Collection {...props} /> : <Redirect to={defaultPath} />;
}}
/>
<Route
path="/collections/:name/new"
render={props => <Editor {...props} newRecord />}