Selaa lähdekoodia

Check if it is creatable

Shun Miyazawa 4 vuotta sitten
vanhempi
sitoutus
733caf736d
1 muutettua tiedostoa jossa 16 lisäystä ja 13 poistoa
  1. 16 13
      packages/app/src/components/Sidebar/PageTree/Item.tsx

+ 16 - 13
packages/app/src/components/Sidebar/PageTree/Item.tsx

@@ -262,20 +262,23 @@ const Item: FC<ItemProps> = (props: ItemProps) => {
     const parentPath = pathUtils.addTrailingSlash(page.path as string);
     const parentPath = pathUtils.addTrailingSlash(page.path as string);
     const newPagePath = `${parentPath}${inputText}`;
     const newPagePath = `${parentPath}${inputText}`;
     const initialBody = `# ${newPagePath}`;
     const initialBody = `# ${newPagePath}`;
+    const isCreatable = pagePathUtils.isCreatablePage(newPagePath);
+
+    if (isCreatable) {
+      const body = {
+        path: newPagePath,
+        body: initialBody,
+        grant: page.grant,
+        grantUserGroupId: page.grantedGroup,
+      };
 
 
-    const body = {
-      path: newPagePath,
-      body: initialBody,
-      grant: page.grant,
-      grantUserGroupId: page.grantedGroup,
-    };
-
-    try {
-      await apiv3Post('/pages/', body);
-      mutateChildren();
-    }
-    catch (err) {
-      toastError(err);
+      try {
+        await apiv3Post('/pages/', body);
+        mutateChildren();
+      }
+      catch (err) {
+        toastError(err);
+      }
     }
     }
   };
   };