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

add translations and show GrantedGroupInheritanceSelectModal for memo and templates

Futa Arai 2 лет назад
Родитель
Сommit
05ca470c93

+ 6 - 0
apps/app/public/static/locales/en_US/translation.json

@@ -421,6 +421,12 @@
     }
   },
   "duplicated_pages": "{{fromPath}} has been duplicated",
+  "modal_granted_groups_inheritance_select": {
+    "select_granted_groups": "Select groups that can access page",
+    "inherit_all_granted_groups_from_parent": "Inherit all groups that can access page from parent",
+    "only_inherit_related_groups": "Only inherit groups that you belong to from parent",
+    "create_page": "Create Page"
+  },
   "modal_putback": {
     "label": {
       "Put Back Page": "Put back page",

+ 6 - 0
apps/app/public/static/locales/ja_JP/translation.json

@@ -454,6 +454,12 @@
     }
   },
   "duplicated_pages": "{{fromPath}} を複製しました",
+  "modal_granted_groups_inheritance_select": {
+    "select_granted_groups": "閲覧権限のあるグループを選択",
+    "inherit_all_granted_groups_from_parent": "閲覧権限のあるグループを親ページから全て引き継ぐ",
+    "only_inherit_related_groups": "自分が所属するグループのみを親ページから引き継ぐ",
+    "create_page": "ページ作成"
+  },
   "modal_putback": {
     "label": {
       "Put Back Page": "ページを元に戻す",

+ 6 - 0
apps/app/public/static/locales/zh_CN/translation.json

@@ -411,6 +411,12 @@
     }
   },
   "duplicated_pages": "{{fromPath}} 已重复",
+  "modal_granted_groups_inheritance_select": {
+    "select_granted_groups": "Select groups that can access page",
+    "inherit_all_granted_groups_from_parent": "Inherit all groups that can access page from parent",
+    "only_inherit_related_groups": "Only inherit groups that you belong to from parent",
+    "create_page": "Create Page"
+  },
   "modal_putback": {
     "label": {
       "Put Back Page": "Put back page",

+ 2 - 2
apps/app/src/client/services/create-page/use-create-page-and-transit.tsx

@@ -60,7 +60,7 @@ export const useCreatePageAndTransit: UseCreatePageAndTransit = () => {
       onCreationStart, onCreated, onAborted, onTerminated,
     } = opts;
 
-    if (params?.parentPath != null && params?.onlyInheritUserRelatedGrantedGroups == null) {
+    if (params.parentPath != null && params?.onlyInheritUserRelatedGrantedGroups == null) {
       try {
         const { isNonUserRelatedGroupsGranted } = await nonUserRelatedGroupsGranted(params.parentPath);
         if (isNonUserRelatedGroupsGranted) {
@@ -121,7 +121,7 @@ export const useCreatePageAndTransit: UseCreatePageAndTransit = () => {
       setCreating(false);
     }
 
-  }, [currentPagePath, mutateEditorMode, router]);
+  }, [currentPagePath, mutateEditorMode, router, openGrantedGroupsInheritanceSelectModal]);
 
   return {
     isCreating,

+ 3 - 1
apps/app/src/client/services/create-page/use-create-template-page.ts

@@ -27,7 +27,9 @@ export const useCreateTemplatePage: UseCreateTemplatePage = () => {
     if (isLoadingPagePath || !isCreatable) return;
 
     return createAndTransit(
-      { path: normalizePath(`${currentPagePath}/${label}`), wip: false, origin: Origin.View },
+      {
+        path: normalizePath(`${currentPagePath}/${label}`), parentPath: currentPagePath, wip: false, origin: Origin.View,
+      },
       { shouldCheckPageExists: true },
     );
   }, [currentPagePath, isCreatable, isLoadingPagePath, createAndTransit]);

+ 4 - 4
apps/app/src/components/GrantedGroupInheritanceSelectModal.tsx → apps/app/src/components/GrantedGroupsInheritanceSelectModal.tsx

@@ -30,7 +30,7 @@ export const GrantedGroupsInheritanceSelectModal = (): JSX.Element => {
       toggle={() => closeModal()}
     >
       <ModalHeader tag="h4" toggle={() => closeModal()} className="bg-primary text-light">
-        閲覧権限のあるグループを選択
+        {t('modal_granted_groups_inheritance_select.select_granted_groups')}
       </ModalHeader>
       <ModalBody>
         <div className="p-3">
@@ -44,7 +44,7 @@ export const GrantedGroupsInheritanceSelectModal = (): JSX.Element => {
               onChange={() => { setOnlyInheritUserRelatedGrantedGroups(false) }}
             />
             <label className="form-check-label" htmlFor="inheritAllGroupsRadio">
-              閲覧権限のあるグループを親ページから全て引き継ぐ
+              {t('modal_granted_groups_inheritance_select.inherit_all_granted_groups_from_parent')}
             </label>
           </div>
           <div className="form-check radio-primary mb-4">
@@ -57,11 +57,11 @@ export const GrantedGroupsInheritanceSelectModal = (): JSX.Element => {
               onChange={() => { setOnlyInheritUserRelatedGrantedGroups(true) }}
             />
             <label className="form-check-label" htmlFor="onlyInheritRelatedGroupsRadio">
-              自分が所属するグループのみを親ページから引き継ぐ
+              {t('modal_granted_groups_inheritance_select.only_inherit_related_groups')}
             </label>
           </div>
           <div className="text-center">
-            <button className="btn btn-primary" type="button" onClick={onCreateBtnClick}>{t('Create')}</button>
+            <button className="btn btn-primary" type="button" onClick={onCreateBtnClick}>{t('modal_granted_groups_inheritance_select.create_page')}</button>
           </div>
         </div>
       </ModalBody>

+ 6 - 3
apps/app/src/components/Sidebar/PageCreateButton/hooks/use-create-todays-memo.tsx

@@ -25,18 +25,21 @@ export const useCreateTodaysMemo: UseCreateTodaysMemo = () => {
 
   const parentDirName = t('create_page_dropdown.todays.memo');
   const now = format(new Date(), 'yyyy/MM/dd');
+  const parentPath = `${userHomepagePath(currentUser)}/${parentDirName}`;
   const todaysPath = isCreatable
-    ? `${userHomepagePath(currentUser)}/${parentDirName}/${now}`
+    ? `${parentPath}/${now}`
     : null;
 
   const createTodaysMemo = useCallback(async() => {
     if (!isCreatable || todaysPath == null) return;
 
     return createAndTransit(
-      { path: todaysPath, wip: true, origin: Origin.View },
+      {
+        path: todaysPath, parentPath, wip: true, origin: Origin.View,
+      },
       { shouldCheckPageExists: true },
     );
-  }, [createAndTransit, isCreatable, todaysPath]);
+  }, [createAndTransit, isCreatable, todaysPath, parentPath]);
 
   return {
     isCreating,

+ 1 - 1
apps/app/src/pages/[[...path]].page.tsx

@@ -21,7 +21,7 @@ import { useRouter } from 'next/router';
 import superjson from 'superjson';
 
 import { useEditorModeClassName } from '~/client/services/layout';
-import { GrantedGroupsInheritanceSelectModal } from '~/components/GrantedGroupInheritanceSelectModal';
+import { GrantedGroupsInheritanceSelectModal } from '~/components/GrantedGroupsInheritanceSelectModal';
 import { PageView } from '~/components/Page/PageView';
 import { DrawioViewerScript } from '~/components/Script/DrawioViewerScript';
 import { SupportedAction, type SupportedActionType } from '~/interfaces/activity';