Ver Fonte

Merge pull request #3027 from weseek/imprv/gw4317-coundnt-create-page

improve could'nt create page
Yuki Takei há 5 anos atrás
pai
commit
718897be8a

+ 3 - 1
src/client/js/legacy/crowi.js

@@ -156,12 +156,14 @@ Crowi.highlightSelectedSection = function(hash) {
 
 
 window.addEventListener('load', (e) => {
 window.addEventListener('load', (e) => {
   const { appContainer } = window;
   const { appContainer } = window;
+  const pageContainer = appContainer.getContainer('PageContainer');
+  const { isEditable } = pageContainer;
 
 
   // hash on page
   // hash on page
   if (window.location.hash) {
   if (window.location.hash) {
     const navigationContainer = appContainer.getContainer('NavigationContainer');
     const navigationContainer = appContainer.getContainer('NavigationContainer');
 
 
-    if (window.location.hash === '#edit') {
+    if (window.location.hash === '#edit' && isEditable) {
       navigationContainer.setEditorMode('edit');
       navigationContainer.setEditorMode('edit');
 
 
       // focus
       // focus

+ 13 - 0
src/client/js/services/PageContainer.js

@@ -139,6 +139,19 @@ export default class PageContainer extends Container {
     return 'PageContainer';
     return 'PageContainer';
   }
   }
 
 
+
+  get isEditable() {
+    const { currentUser } = this.appContainer;
+    const {
+      isPageExist, isPageForbidden, isNotCreatable, isTrashPage,
+    } = this.state;
+
+    if (isPageExist && (currentUser != null) && !isPageForbidden && !isNotCreatable && !isTrashPage) {
+      return true;
+    }
+    return false;
+  }
+
   /**
   /**
    * initialize state for markdown data
    * initialize state for markdown data
    */
    */

+ 1 - 1
src/server/views/widget/not_creatable_content.html

@@ -1,4 +1,4 @@
-<div class="row not-found-message-row mb-4">
+<div class="row not-found-message-row">
   <div class="col-md-12">
   <div class="col-md-12">
     <h2 class="text-muted">
     <h2 class="text-muted">
       <i class="icon-ban" aria-hidden="true"></i>
       <i class="icon-ban" aria-hidden="true"></i>