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

Merge pull request #5780 from weseek/imprv/plpages-convert-modal-style-i18n

imprv: Add style to private legacy pages convert modal & i18n
Yuki Takei 4 лет назад
Родитель
Сommit
a01c89e4e9

+ 8 - 0
packages/app/resource/locales/en_US/translation.json

@@ -642,6 +642,7 @@
   "private_legacy_pages": {
     "bulk_operation": "Bulk operation",
     "convert_all_selected_pages": "Convert all to new v5 compatible format",
+    "input_path_to_convert": "Input a path to convert pages",
     "alert_title": "Old v4 compatible format private pages exist.",
     "alert_desc1": "On this page, you can select pages with the checkbox and batch convert to the new v5 compatible format from the \"Bulk operation\" button at the top of the screen.",
     "nopages_title": "Congratulations. Ready to use GROWI v5!",
@@ -653,6 +654,13 @@
       "convert_recursively_label": "Convert child pages recursively.",
       "convert_recursively_desc": "Convert pages under this path recursively.",
       "button_label": "Convert"
+    },
+    "by_path_modal": {
+      "title": "Convert to new v5 compatible format",
+      "description": "Enter a path and all pages under that path will be converted to v5 compatible format.",
+      "button_label": "Convert",
+      "success": "Successfully requested conversion.",
+      "error": "Failed to request conversion."
     }
   },
   "security_setting": {

+ 8 - 0
packages/app/resource/locales/ja_JP/translation.json

@@ -641,6 +641,7 @@
   "private_legacy_pages": {
     "bulk_operation": "一括操作",
     "convert_all_selected_pages": "新しい v5 互換形式に一括変換",
+    "input_path_to_convert": "パスを入力して変換",
     "alert_title": "古い v4 互換形式のプライベートページが存在します",
     "alert_desc1": "このページでは、チェックボックスでページを選択し、画面上部の「一括操作」ボタンから新しい v5 互換形式に一括変換できます。",
     "nopages_title": "おめでとうございます。GROWI v5 を使う準備が完了しました!",
@@ -652,6 +653,13 @@
       "convert_recursively_label": "再起的に変換",
       "convert_recursively_desc": "このページの配下のページを再起的に変換します",
       "button_label": "変換"
+    },
+    "by_path_modal": {
+      "title": "新しい v5 互換形式への変換",
+      "description": "パスを入力することで、そのパスの配下のページを全て v5 互換形式に変換します",
+      "button_label": "変換",
+      "success": "正常に変換を開始しました",
+      "error": "変換を開始できませんでした"
     }
   },
   "security_setting": {

+ 8 - 0
packages/app/resource/locales/zh_CN/translation.json

@@ -928,6 +928,7 @@
   "private_legacy_pages": {
     "bulk_operation": "批量操作",
     "convert_all_selected_pages": "全部转换为新的v5兼容格式",
+		"input_path_to_convert": "输入一个转换页面的路径",
     "alert_title": "存在旧的v4兼容格式的私人网页。",
     "alert_desc1": "在这一页,你可以用复选框选择页面,并通过屏幕上方的批量操作按钮批量转换为新的v5兼容格式。",
     "nopages_title": "恭喜你。准备使用GROWI v5!",
@@ -939,6 +940,13 @@
       "convert_recursively_label": "递归地转换子页面。",
       "convert_recursively_desc": "递归地转换该路径下的页面。",
       "button_label": "转换"
+    },
+    "by_path_modal": {
+      "title": "转换为新的v5兼容格式",
+      "description": "输入一个路径,该路径下的所有页面将被转换为v5兼容格式。",
+      "button_label": "转换",
+      "success": "成功地请求转换。",
+      "error": "请求转换失败。"
     }
   },
 	"to_cloud_settings": "進入 GROWI.cloud 的管理界面",

+ 8 - 10
packages/app/src/components/PrivateLegacyPages.tsx

@@ -141,17 +141,16 @@ const ConvertByPathModal = React.memo((props: ConvertByPathModalProps): JSX.Elem
   return (
     <Modal size="lg" isOpen={props.isOpen} toggle={props.close} className="grw-create-page">
       <ModalHeader tag="h4" toggle={props.close} className="bg-primary text-light">
-        { t('private_legacy_pages.modal.title') }
+        { t('private_legacy_pages.by_path_modal.title') }
       </ModalHeader>
       <ModalBody>
-        {/* TODO: i18n */}
-        <p>{t('modal_description')}</p>
+        <p>{t('private_legacy_pages.by_path_modal.description')}</p>
         <input type="text" className="form-control" placeholder="/" value={currentInput} onChange={e => setInput(e.target.value)} />
       </ModalBody>
       <ModalFooter>
-        <button type="button" className="btn btn-primary" onSubmit={(e) => { e.preventDefault(); props.onSubmit?.(currentInput) }}>
+        <button type="button" className="btn btn-primary" onClick={() => props.onSubmit?.(currentInput)}>
           <i className="icon-fw icon-refresh" aria-hidden="true"></i>
-          { t('private_legacy_pages.modal.button_label') }
+          { t('private_legacy_pages.by_path_modal.button_label') }
         </button>
       </ModalFooter>
     </Modal>
@@ -319,7 +318,7 @@ const PrivateLegacyPages = (props: Props): JSX.Element => {
         </div>
         <div className="d-flex pl-md-2">
           <button type="button" className="btn btn-light" onClick={() => setOpenConvertModal(true)}>
-            Input the path to convert
+            {t('private_legacy_pages.input_path_to_convert')}
           </button>
         </div>
       </div>
@@ -396,12 +395,11 @@ const PrivateLegacyPages = (props: Props): JSX.Element => {
             await apiv3Post<void>('/pages/legacy-pages-migration', {
               convertPath,
             });
-            // TODO: i18n
-            toastSuccess(t('success_message'));
+            toastSuccess(t('private_legacy_pages.by_path_modal.success'));
+            setOpenConvertModal(false);
           }
           catch {
-            // TODO: i18n
-            toastError(t('error_message'));
+            toastError(t('private_legacy_pages.by_path_modal.error'));
           }
         }}
       />

+ 2 - 7
packages/app/src/server/service/page.ts

@@ -2279,13 +2279,8 @@ class PageService {
       throw err;
     }
 
-    try {
-      await this.normalizeParentRecursivelyMainOperation(page, user, pageOp._id);
-    }
-    catch (err) {
-      logger.err('Failed to run normalizeParentRecursivelyMainOperation.', err);
-      throw err;
-    }
+    // no await
+    this.normalizeParentRecursivelyMainOperation(page, user, pageOp._id);
   }
 
   async normalizeParentByPageIds(pageIds: ObjectIdLike[], user, isRecursively: boolean): Promise<void> {