Sfoglia il codice sorgente

Merge pull request #5783 from weseek/feat/93812-page-migratoin-toast-frontend

feat: 93812 page migratoin toast frontend
Haku Mizuki 4 anni fa
parent
commit
b44ab1948b

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

@@ -653,6 +653,11 @@
       "convert_recursively_label": "Convert child pages recursively.",
       "convert_recursively_label": "Convert child pages recursively.",
       "convert_recursively_desc": "Convert pages under this path recursively.",
       "convert_recursively_desc": "Convert pages under this path recursively.",
       "button_label": "Convert"
       "button_label": "Convert"
+    },
+    "toaster": {
+      "page_migration_succeeded": "Conversion of page to v5 has been successfully completed.",
+      "page_migration_failed_with_paths": "Conversion of {{paths}} to v5 has been failed.",
+      "page_migration_failed": "Conversion of page to v5 has been failed."
     }
     }
   },
   },
   "security_setting": {
   "security_setting": {

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

@@ -652,6 +652,11 @@
       "convert_recursively_label": "再起的に変換",
       "convert_recursively_label": "再起的に変換",
       "convert_recursively_desc": "このページの配下のページを再起的に変換します",
       "convert_recursively_desc": "このページの配下のページを再起的に変換します",
       "button_label": "変換"
       "button_label": "変換"
+    },
+    "toaster": {
+      "page_migration_succeeded": "ページの v5 互換形式への変換が正常に終了しました。",
+      "page_migration_failed_with_paths": "{{paths}} の v5 互換形式への変換中にエラーが発生しました。",
+      "page_migration_failed": "ページの v5 互換形式への変換中にエラーが発生しました。"
     }
     }
   },
   },
   "security_setting": {
   "security_setting": {

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

@@ -939,6 +939,11 @@
       "convert_recursively_label": "递归地转换子页面。",
       "convert_recursively_label": "递归地转换子页面。",
       "convert_recursively_desc": "递归地转换该路径下的页面。",
       "convert_recursively_desc": "递归地转换该路径下的页面。",
       "button_label": "转换"
       "button_label": "转换"
+    },
+    "toaster": {
+      "page_migration_succeeded": "页面到 v5 兼容格式的转换已成功完成。",
+      "page_migration_failed_with_paths": "将 {{paths}} 转换为 v5 兼容格式时出错",
+      "page_migration_failed": "将页面转换为 v5 兼容格式时出错。"
     }
     }
   },
   },
 	"to_cloud_settings": "進入 GROWI.cloud 的管理界面",
 	"to_cloud_settings": "進入 GROWI.cloud 的管理界面",

+ 12 - 4
packages/app/src/components/PrivateLegacyPages.tsx

@@ -9,7 +9,7 @@ import {
 
 
 import { ISelectableAll, ISelectableAndIndeterminatable } from '~/client/interfaces/selectable-all';
 import { ISelectableAll, ISelectableAndIndeterminatable } from '~/client/interfaces/selectable-all';
 import AppContainer from '~/client/services/AppContainer';
 import AppContainer from '~/client/services/AppContainer';
-import { toastSuccess } from '~/client/util/apiNotification';
+import { toastSuccess, toastError } from '~/client/util/apiNotification';
 import { V5MigrationStatus } from '~/interfaces/page-listing-results';
 import { V5MigrationStatus } from '~/interfaces/page-listing-results';
 import { IFormattedSearchResult } from '~/interfaces/search';
 import { IFormattedSearchResult } from '~/interfaces/search';
 import { PageMigrationErrorData, SocketEventName } from '~/interfaces/websocket';
 import { PageMigrationErrorData, SocketEventName } from '~/interfaces/websocket';
@@ -171,11 +171,19 @@ export const PrivateLegacyPages = (props: Props): JSX.Element => {
 
 
   useEffect(() => {
   useEffect(() => {
     socket?.on(SocketEventName.PageMigrationSuccess, () => {
     socket?.on(SocketEventName.PageMigrationSuccess, () => {
-      // page migration success
+      toastSuccess(t('private_legacy_pages.toaster.page_migration_succeeded'));
     });
     });
 
 
-    socket?.on(SocketEventName.PageMigrationError, (data: PageMigrationErrorData) => {
-      // page migration error
+    socket?.on(SocketEventName.PageMigrationError, (data?: PageMigrationErrorData) => {
+      if (data == null || data.paths.length === 0) {
+        toastError(t('private_legacy_pages.toaster.page_migration_failed'));
+      }
+      else {
+        const errorPaths = data.paths.length > 3
+          ? `${data.paths.slice(0, 3).join(', ')}...`
+          : data.paths.join(', ');
+        toastError(t('private_legacy_pages.toaster.page_migration_failed_with_paths', { paths: errorPaths }));
+      }
     });
     });
 
 
     return () => {
     return () => {