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

add create able page condition

ryoji-s 2 лет назад
Родитель
Сommit
2b4b1b46da
1 измененных файлов с 4 добавлено и 1 удалено
  1. 4 1
      apps/app/src/components/Sidebar/PageCreateButton.tsx

+ 4 - 1
apps/app/src/components/Sidebar/PageCreateButton.tsx

@@ -1,5 +1,6 @@
 import React, { useCallback, useState } from 'react';
 import React, { useCallback, useState } from 'react';
 
 
+import { isCreatablePage } from '@growi/core/dist/utils/page-path-utils';
 import { useRouter } from 'next/router';
 import { useRouter } from 'next/router';
 
 
 import { apiv3Post } from '~/client/util/apiv3-client';
 import { apiv3Post } from '~/client/util/apiv3-client';
@@ -28,7 +29,9 @@ export const PageCreateButton = React.memo((): JSX.Element => {
     if (isLoading) return;
     if (isLoading) return;
 
 
     try {
     try {
-      const parentPath = currentPage?.path || '/';
+      const parentPath = currentPage == null || isCreatablePage(currentPage.path)
+        ? '/'
+        : currentPage.path;
 
 
       const response = await apiv3Post('/pages/', {
       const response = await apiv3Post('/pages/', {
         path: parentPath,
         path: parentPath,