Просмотр исходного кода

delete "create page " in forbidden page

zahmis 5 лет назад
Родитель
Сommit
dbd6196afb
2 измененных файлов с 7 добавлено и 2 удалено
  1. 1 1
      src/client/js/app.jsx
  2. 6 1
      src/client/js/components/Page/NotFoundAlert.jsx

+ 1 - 1
src/client/js/app.jsx

@@ -80,7 +80,7 @@ Object.assign(componentMappings, {
 
   'not-found-page': <NotFoundPage />,
 
-  'not-found-alert': <NotFoundAlert onPageCreateClicked={navigationContainer.setEditorMode} />,
+  'not-found-alert': <NotFoundAlert onPageCreateClicked={navigationContainer.setEditorMode} isForbidden={pageContainer.isForbidden} />,
 
   'page-timeline': <PageTimeline />,
 

+ 6 - 1
src/client/js/components/Page/NotFoundAlert.jsx

@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
 import { withTranslation } from 'react-i18next';
 
 const NotFoundAlert = (props) => {
-  const { t } = props;
+  const { t, isForbidden } = props;
   function clickHandler(viewType) {
     if (props.onPageCreateClicked === null) {
       return;
@@ -11,6 +11,10 @@ const NotFoundAlert = (props) => {
     props.onPageCreateClicked(viewType);
   }
 
+  if (!isForbidden) {
+    return null;
+  }
+
   return (
     <div className="border border-info m-4 p-3">
       <div className="col-md-12 p-0">
@@ -35,6 +39,7 @@ const NotFoundAlert = (props) => {
 NotFoundAlert.propTypes = {
   t: PropTypes.func.isRequired, // i18next
   onPageCreateClicked: PropTypes.func,
+  isForbidden: PropTypes.bool,
 };
 
 export default withTranslation()(NotFoundAlert);