Handle Admin page 404

This commit is contained in:
cyril lopez 2017-12-06 16:40:32 +01:00
parent 9a2e051361
commit 63c5c73aee

View File

@ -60,6 +60,18 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
}
}
componentWillUpdate(nextProps) {
if (includes(nextProps.location.pathname, 'plugins') && nextProps.location.pathname !== '/list-plugins') {
const appPlugins = Object.keys(nextProps.plugins.toJS());
const pluginPath = nextProps.location.pathname.split('/')[2];
const shouldRedirect = appPlugins.filter(el => el === pluginPath).length === 0;
if (shouldRedirect) {
this.props.history.push('/404');
}
}
}
checkLogin = (props) => {
if (props.hasUserPlugin && this.isUrlProtected(props) && !auth.getToken()) {
const endPoint = this.hasAdminUser(props) ? 'login': 'register';
@ -122,6 +134,7 @@ export class AdminPage extends React.Component { // eslint-disable-line react/pr
<Route path="/install-plugin" component={ComingSoonPage} exact />
<Route path="/configuration" component={ComingSoonPage} exact />
<Route path="" component={NotFoundPage} />
<Route path="404" component={NotFoundPage} />
</Switch>
</Content>
</div>