ryoji-s 2 лет назад
Родитель
Сommit
84227841b2

+ 5 - 2
apps/app/src/components/Sidebar/PageCreateButton/PageCreateButton.tsx

@@ -9,7 +9,7 @@ import { useOnTemplateButtonClicked } from '~/client/services/use-on-template-bu
 import { toastError } from '~/client/util/toastr';
 import { LabelType } from '~/interfaces/template';
 import { useCurrentUser } from '~/stores/context';
-import { useSWRxCurrentPage } from '~/stores/page';
+import { useCurrentPagePath, useSWRxCurrentPage } from '~/stores/page';
 
 import { CreateButton } from './CreateButton';
 import { DropendMenu } from './DropendMenu';
@@ -25,6 +25,7 @@ const generateTodaysPath = (currentUser: IUserHasId, parentDirName: string) => {
 export const PageCreateButton = React.memo((): JSX.Element => {
   const { t } = useTranslation('commons');
 
+  const { data: currentPagePath, isLoading: isLoadingPagePath } = useCurrentPagePath();
   const { data: currentPage, isLoading } = useSWRxCurrentPage();
   const { data: currentUser } = useCurrentUser();
 
@@ -35,8 +36,10 @@ export const PageCreateButton = React.memo((): JSX.Element => {
     : generateTodaysPath(currentUser, t('create_page_dropdown.todays.memo'));
 
   const { onClickHandler: onClickNewButton, isPageCreating: isNewPageCreating } = useOnNewButtonClicked(currentPage, isLoading);
+  // TODO: https://redmine.weseek.co.jp/issues/138806
   const { onClickHandler: onClickTodaysButton, isPageCreating: isTodaysPageCreating } = useOnTodaysButtonClicked(todaysPath);
-  const { onClickHandler: onClickTemplateButton, isPageCreating: isTemplatePageCreating } = useOnTemplateButtonClicked(currentPagePath, isLoading);
+  // TODO: https://redmine.weseek.co.jp/issues/138805
+  const { onClickHandler: onClickTemplateButton, isPageCreating: isTemplatePageCreating } = useOnTemplateButtonClicked(currentPagePath, isLoadingPagePath);
 
   const onClickTemplateButtonHandler = useCallback(async(label: LabelType) => {
     try {

+ 6 - 6
apps/app/src/components/Sidebar/PageCreateButton/hooks.tsx

@@ -22,10 +22,11 @@ export const useOnNewButtonClicked = (
     try {
       setIsPageCreating(true);
 
-      // !! NOTICE !!
-      // Verification of page createable or not is done on the server side.
-      // Since the new page path is not generated on the client side.
-      // Need shouldGeneratePath flag.
+      /**
+       * !! NOTICE !! - Verification of page createable or not is checked on the server side.
+       * since the new page path is not generated on the client side.
+       * need shouldGeneratePath flag.
+       */
       const shouldUseRootPath = currentPage?.path == null;
       const parentPath = shouldUseRootPath
         ? '/'
@@ -39,8 +40,7 @@ export const useOnNewButtonClicked = (
         shouldGeneratePath: true,
       };
 
-      // !! NOTICE !!
-      // If shouldGeneratePath is flagged, send the parent page path
+      // !! NOTICE !! - if shouldGeneratePath is flagged, send the parent page path
       const response = await createPage(parentPath, '', params);
 
       router.push(`/${response.page.id}#edit`);

+ 2 - 2
apps/app/src/server/routes/apiv3/pages.js

@@ -327,10 +327,10 @@ module.exports = (crowi) => {
         const basePath = path === rootPath ? defaultTitle : path + defaultTitle;
         path = await generateUniquePath(basePath);
 
-        // If the generated path is not creatable, create the path under the root path.
+        // if the generated path is not creatable, create the path under the root path
         if (!isCreatablePage(path)) {
           path = await generateUniquePath(defaultTitle);
-          // Initialize grant data when creating under root
+          // initialize grant data
           grant = 1;
           grantUserGroupIds = null;
         }