mirror of
https://github.com/strapi/strapi.git
synced 2025-12-12 15:32:42 +00:00
Add 404 in settings manager
This commit is contained in:
parent
63c5c73aee
commit
c2fd6468b4
@ -13,7 +13,7 @@ import { bindActionCreators, compose } from 'redux';
|
||||
import 'flag-icon-css/css/flag-icon.css';
|
||||
import 'react-select/dist/react-select.css';
|
||||
import { Switch, Route } from 'react-router-dom';
|
||||
|
||||
import { isEmpty } from 'lodash';
|
||||
import { pluginId } from 'app';
|
||||
|
||||
import injectSaga from 'utils/injectSaga';
|
||||
@ -21,7 +21,7 @@ import injectSaga from 'utils/injectSaga';
|
||||
import HomePage from 'containers/HomePage';
|
||||
|
||||
import { menuFetch, environmentsFetch } from './actions';
|
||||
import { makeSelectLoading } from './selectors';
|
||||
import { makeSelectLoading, makeSelectSections } from './selectors';
|
||||
import styles from './styles.scss';
|
||||
|
||||
import saga from './sagas';
|
||||
@ -33,6 +33,26 @@ class App extends React.Component {
|
||||
this.props.environmentsFetch();
|
||||
}
|
||||
|
||||
componentWillUpdate(nextProps) {
|
||||
if (!isEmpty(nextProps.sections) && nextProps.location.pathname !== '/plugins/settings-manager') {
|
||||
const allowedPath = nextProps.sections.reduce((acc, current) => {
|
||||
const slugs = current.items.reduce((acc, current) => {
|
||||
acc.push(current.slug);
|
||||
|
||||
return acc;
|
||||
}, []);
|
||||
return acc.concat(slugs);
|
||||
}, []);
|
||||
|
||||
const slug = nextProps.location.pathname.split('/')[3];
|
||||
const shouldRedirect = allowedPath.filter(el => el === slug).length === 0;
|
||||
|
||||
if (shouldRedirect) {
|
||||
this.props.history.push('/404');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
render() {
|
||||
return (
|
||||
<div className={`${pluginId} ${styles.app}`}>
|
||||
@ -52,8 +72,9 @@ App.contextTypes = {
|
||||
|
||||
App.propTypes = {
|
||||
environmentsFetch: PropTypes.func.isRequired,
|
||||
// loading: PropTypes.bool.isRequired,
|
||||
history: PropTypes.object.isRequired,
|
||||
menuFetch: PropTypes.func.isRequired,
|
||||
sections: PropTypes.array.isRequired,
|
||||
};
|
||||
|
||||
export function mapDispatchToProps(dispatch) {
|
||||
@ -68,6 +89,7 @@ export function mapDispatchToProps(dispatch) {
|
||||
|
||||
const mapStateToProps = createStructuredSelector({
|
||||
loading: makeSelectLoading(),
|
||||
sections: makeSelectSections(),
|
||||
});
|
||||
|
||||
// Wrap the component to inject dispatch and state into it
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user